]>
git.saurik.com Git - apt.git/blob - methods/http.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: http.cc,v 1.59 2004/05/08 19:42:35 mdz Exp $
4 /* ######################################################################
6 HTTP Aquire Method - This is the HTTP aquire method for APT.
8 It uses HTTP/1.1 and many of the fancy options there-in, such as
9 pipelining, range, if-range and so on.
11 It is based on a doubly buffered select loop. A groupe of requests are
12 fed into a single output buffer that is constantly fed out the
13 socket. This provides ideal pipelining as in many cases all of the
14 requests will fit into a single packet. The input socket is buffered
15 the same way and fed into the fd for the file (may be a pipe in future).
17 This double buffering provides fairly substantial transfer rates,
18 compared to wget the http method is about 4% faster. Most importantly,
19 when HTTP is compared with FTP as a protocol the speed difference is
20 huge. In tests over the internet from two sites to llug (via ATM) this
21 program got 230k/s sustained http transfer rates. FTP on the other
22 hand topped out at 170k/s. That combined with the time to setup the
23 FTP connection makes HTTP a vastly superior protocol.
25 ##################################################################### */
27 // Include Files /*{{{*/
28 #include <apt-pkg/fileutl.h>
29 #include <apt-pkg/acquire-method.h>
30 #include <apt-pkg/error.h>
31 #include <apt-pkg/hashes.h>
48 #include "rfc2553emu.h"
54 string
HttpMethod::FailFile
;
55 int HttpMethod::FailFd
= -1;
56 time_t HttpMethod::FailTime
= 0;
57 unsigned long PipelineDepth
= 10;
58 unsigned long TimeOut
= 120;
61 // CircleBuf::CircleBuf - Circular input buffer /*{{{*/
62 // ---------------------------------------------------------------------
64 CircleBuf::CircleBuf(unsigned long Size
) : Size(Size
), Hash(0)
66 Buf
= new unsigned char[Size
];
70 // CircleBuf::Reset - Reset to the default state /*{{{*/
71 // ---------------------------------------------------------------------
73 void CircleBuf::Reset()
78 MaxGet
= (unsigned int)-1;
87 // CircleBuf::Read - Read from a FD into the circular buffer /*{{{*/
88 // ---------------------------------------------------------------------
89 /* This fills up the buffer with as much data as is in the FD, assuming it
91 bool CircleBuf::Read(int Fd
)
95 // Woops, buffer is full
96 if (InP
- OutP
== Size
)
99 // Write the buffer segment
101 Res
= read(Fd
,Buf
+ (InP%Size
),LeftRead());
113 gettimeofday(&Start
,0);
118 // CircleBuf::Read - Put the string into the buffer /*{{{*/
119 // ---------------------------------------------------------------------
120 /* This will hold the string in and fill the buffer with it as it empties */
121 bool CircleBuf::Read(string Data
)
128 // CircleBuf::FillOut - Fill the buffer from the output queue /*{{{*/
129 // ---------------------------------------------------------------------
131 void CircleBuf::FillOut()
133 if (OutQueue
.empty() == true)
137 // Woops, buffer is full
138 if (InP
- OutP
== Size
)
141 // Write the buffer segment
142 unsigned long Sz
= LeftRead();
143 if (OutQueue
.length() - StrPos
< Sz
)
144 Sz
= OutQueue
.length() - StrPos
;
145 memcpy(Buf
+ (InP%Size
),OutQueue
.c_str() + StrPos
,Sz
);
150 if (OutQueue
.length() == StrPos
)
159 // CircleBuf::Write - Write from the buffer into a FD /*{{{*/
160 // ---------------------------------------------------------------------
161 /* This empties the buffer into the FD. */
162 bool CircleBuf::Write(int Fd
)
168 // Woops, buffer is empty
175 // Write the buffer segment
177 Res
= write(Fd
,Buf
+ (OutP%Size
),LeftWrite());
190 Hash
->Add(Buf
+ (OutP%Size
),Res
);
196 // CircleBuf::WriteTillEl - Write from the buffer to a string /*{{{*/
197 // ---------------------------------------------------------------------
198 /* This copies till the first empty line */
199 bool CircleBuf::WriteTillEl(string
&Data
,bool Single
)
201 // We cheat and assume it is unneeded to have more than one buffer load
202 for (unsigned long I
= OutP
; I
< InP
; I
++)
204 if (Buf
[I%Size
] != '\n')
207 if (I
< InP
&& Buf
[I%Size
] == '\r')
212 if (Buf
[I%Size
] != '\n')
215 if (I
< InP
&& Buf
[I%Size
] == '\r')
225 unsigned long Sz
= LeftWrite();
228 if (I
- OutP
< LeftWrite())
230 Data
+= string((char *)(Buf
+ (OutP%Size
)),Sz
);
238 // CircleBuf::Stats - Print out stats information /*{{{*/
239 // ---------------------------------------------------------------------
241 void CircleBuf::Stats()
247 gettimeofday(&Stop
,0);
248 /* float Diff = Stop.tv_sec - Start.tv_sec +
249 (float)(Stop.tv_usec - Start.tv_usec)/1000000;
250 clog << "Got " << InP << " in " << Diff << " at " << InP/Diff << endl;*/
254 // ServerState::ServerState - Constructor /*{{{*/
255 // ---------------------------------------------------------------------
257 ServerState::ServerState(URI Srv
,HttpMethod
*Owner
) : Owner(Owner
),
258 In(64*1024), Out(4*1024),
264 // ServerState::Open - Open a connection to the server /*{{{*/
265 // ---------------------------------------------------------------------
266 /* This opens a connection to the server. */
267 bool ServerState::Open()
269 // Use the already open connection if possible.
278 // Determine the proxy setting
279 if (getenv("http_proxy") == 0)
281 string DefProxy
= _config
->Find("Acquire::http::Proxy");
282 string SpecificProxy
= _config
->Find("Acquire::http::Proxy::" + ServerName
.Host
);
283 if (SpecificProxy
.empty() == false)
285 if (SpecificProxy
== "DIRECT")
288 Proxy
= SpecificProxy
;
294 Proxy
= getenv("http_proxy");
296 // Parse no_proxy, a , separated list of domains
297 if (getenv("no_proxy") != 0)
299 if (CheckDomainList(ServerName
.Host
,getenv("no_proxy")) == true)
303 // Determine what host and port to use based on the proxy settings
306 if (Proxy
.empty() == true || Proxy
.Host
.empty() == true)
308 if (ServerName
.Port
!= 0)
309 Port
= ServerName
.Port
;
310 Host
= ServerName
.Host
;
319 // Connect to the remote server
320 if (Connect(Host
,Port
,"http",80,ServerFd
,TimeOut
,Owner
) == false)
326 // ServerState::Close - Close a connection to the server /*{{{*/
327 // ---------------------------------------------------------------------
329 bool ServerState::Close()
336 // ServerState::RunHeaders - Get the headers before the data /*{{{*/
337 // ---------------------------------------------------------------------
338 /* Returns 0 if things are OK, 1 if an IO error occursed and 2 if a header
339 parse error occured */
340 int ServerState::RunHeaders()
344 Owner
->Status(_("Waiting for headers"));
358 if (In
.WriteTillEl(Data
) == false)
364 for (string::const_iterator I
= Data
.begin(); I
< Data
.end(); I
++)
366 string::const_iterator J
= I
;
367 for (; J
!= Data
.end() && *J
!= '\n' && *J
!= '\r';J
++);
368 if (HeaderLine(string(I
,J
)) == false)
373 // 100 Continue is a Nop...
377 // Tidy up the connection persistance state.
378 if (Encoding
== Closes
&& HaveContent
== true)
383 while (Owner
->Go(false,this) == true);
388 // ServerState::RunData - Transfer the data from the socket /*{{{*/
389 // ---------------------------------------------------------------------
391 bool ServerState::RunData()
395 // Chunked transfer encoding is fun..
396 if (Encoding
== Chunked
)
400 // Grab the block size
406 if (In
.WriteTillEl(Data
,true) == true)
409 while ((Last
= Owner
->Go(false,this)) == true);
414 // See if we are done
415 unsigned long Len
= strtol(Data
.c_str(),0,16);
420 // We have to remove the entity trailer
424 if (In
.WriteTillEl(Data
,true) == true && Data
.length() <= 2)
427 while ((Last
= Owner
->Go(false,this)) == true);
430 return !_error
->PendingError();
433 // Transfer the block
435 while (Owner
->Go(true,this) == true)
436 if (In
.IsLimit() == true)
440 if (In
.IsLimit() == false)
443 // The server sends an extra new line before the next block specifier..
448 if (In
.WriteTillEl(Data
,true) == true)
451 while ((Last
= Owner
->Go(false,this)) == true);
458 /* Closes encoding is used when the server did not specify a size, the
459 loss of the connection means we are done */
460 if (Encoding
== Closes
)
463 In
.Limit(Size
- StartPos
);
465 // Just transfer the whole block.
468 if (In
.IsLimit() == false)
472 return !_error
->PendingError();
474 while (Owner
->Go(true,this) == true);
477 return Owner
->Flush(this) && !_error
->PendingError();
480 // ServerState::HeaderLine - Process a header line /*{{{*/
481 // ---------------------------------------------------------------------
483 bool ServerState::HeaderLine(string Line
)
485 if (Line
.empty() == true)
488 // The http server might be trying to do something evil.
489 if (Line
.length() >= MAXLEN
)
490 return _error
->Error(_("Got a single header line over %u chars"),MAXLEN
);
492 string::size_type Pos
= Line
.find(' ');
493 if (Pos
== string::npos
|| Pos
+1 > Line
.length())
495 // Blah, some servers use "connection:closes", evil.
496 Pos
= Line
.find(':');
497 if (Pos
== string::npos
|| Pos
+ 2 > Line
.length())
498 return _error
->Error(_("Bad header line"));
502 // Parse off any trailing spaces between the : and the next word.
503 string::size_type Pos2
= Pos
;
504 while (Pos2
< Line
.length() && isspace(Line
[Pos2
]) != 0)
507 string Tag
= string(Line
,0,Pos
);
508 string Val
= string(Line
,Pos2
);
510 if (stringcasecmp(Tag
.c_str(),Tag
.c_str()+4,"HTTP") == 0)
512 // Evil servers return no version
515 if (sscanf(Line
.c_str(),"HTTP/%u.%u %u %[^\n]",&Major
,&Minor
,
517 return _error
->Error(_("The HTTP server sent an invalid reply header"));
523 if (sscanf(Line
.c_str(),"HTTP %u %[^\n]",&Result
,Code
) != 2)
524 return _error
->Error(_("The HTTP server sent an invalid reply header"));
527 /* Check the HTTP response header to get the default persistance
533 if (Major
== 1 && Minor
<= 0)
542 if (stringcasecmp(Tag
,"Content-Length:") == 0)
544 if (Encoding
== Closes
)
548 // The length is already set from the Content-Range header
552 if (sscanf(Val
.c_str(),"%lu",&Size
) != 1)
553 return _error
->Error(_("The HTTP server sent an invalid Content-Length header"));
557 if (stringcasecmp(Tag
,"Content-Type:") == 0)
563 if (stringcasecmp(Tag
,"Content-Range:") == 0)
567 if (sscanf(Val
.c_str(),"bytes %lu-%*u/%lu",&StartPos
,&Size
) != 2)
568 return _error
->Error(_("The HTTP server sent an invalid Content-Range header"));
569 if ((unsigned)StartPos
> Size
)
570 return _error
->Error(_("This HTTP server has broken range support"));
574 if (stringcasecmp(Tag
,"Transfer-Encoding:") == 0)
577 if (stringcasecmp(Val
,"chunked") == 0)
582 if (stringcasecmp(Tag
,"Connection:") == 0)
584 if (stringcasecmp(Val
,"close") == 0)
586 if (stringcasecmp(Val
,"keep-alive") == 0)
591 if (stringcasecmp(Tag
,"Last-Modified:") == 0)
593 if (StrToTime(Val
,Date
) == false)
594 return _error
->Error(_("Unknown date format"));
602 // HttpMethod::SendReq - Send the HTTP request /*{{{*/
603 // ---------------------------------------------------------------------
604 /* This places the http request in the outbound buffer */
605 void HttpMethod::SendReq(FetchItem
*Itm
,CircleBuf
&Out
)
609 // The HTTP server expects a hostname with a trailing :port
611 string ProperHost
= Uri
.Host
;
614 sprintf(Buf
,":%u",Uri
.Port
);
619 if (Itm
->Uri
.length() >= sizeof(Buf
))
622 /* Build the request. We include a keep-alive header only for non-proxy
623 requests. This is to tweak old http/1.0 servers that do support keep-alive
624 but not HTTP/1.1 automatic keep-alive. Doing this with a proxy server
625 will glitch HTTP/1.0 proxies because they do not filter it out and
626 pass it on, HTTP/1.1 says the connection should default to keep alive
627 and we expect the proxy to do this */
628 if (Proxy
.empty() == true)
629 sprintf(Buf
,"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n",
630 QuoteString(Uri
.Path
,"~").c_str(),ProperHost
.c_str());
633 /* Generate a cache control header if necessary. We place a max
634 cache age on index files, optionally set a no-cache directive
635 and a no-store directive for archives. */
636 sprintf(Buf
,"GET %s HTTP/1.1\r\nHost: %s\r\n",
637 Itm
->Uri
.c_str(),ProperHost
.c_str());
638 // only generate a cache control header if we actually want to
640 if (_config
->FindB("Acquire::http::No-Cache",false) == false)
642 if (Itm
->IndexFile
== true)
643 sprintf(Buf
+strlen(Buf
),"Cache-Control: max-age=%u\r\n",
644 _config
->FindI("Acquire::http::Max-Age",0));
647 if (_config
->FindB("Acquire::http::No-Store",false) == true)
648 strcat(Buf
,"Cache-Control: no-store\r\n");
652 // generate a no-cache header if needed
653 if (_config
->FindB("Acquire::http::No-Cache",false) == true)
654 strcat(Buf
,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
659 // Check for a partial file
661 if (stat(Itm
->DestFile
.c_str(),&SBuf
) >= 0 && SBuf
.st_size
> 0)
663 // In this case we send an if-range query with a range header
664 sprintf(Buf
,"Range: bytes=%li-\r\nIf-Range: %s\r\n",(long)SBuf
.st_size
- 1,
665 TimeRFC1123(SBuf
.st_mtime
).c_str());
670 if (Itm
->LastModified
!= 0)
672 sprintf(Buf
,"If-Modified-Since: %s\r\n",TimeRFC1123(Itm
->LastModified
).c_str());
677 if (Proxy
.User
.empty() == false || Proxy
.Password
.empty() == false)
678 Req
+= string("Proxy-Authorization: Basic ") +
679 Base64Encode(Proxy
.User
+ ":" + Proxy
.Password
) + "\r\n";
681 if (Uri
.User
.empty() == false || Uri
.Password
.empty() == false)
682 Req
+= string("Authorization: Basic ") +
683 Base64Encode(Uri
.User
+ ":" + Uri
.Password
) + "\r\n";
685 Req
+= "User-Agent: Debian APT-HTTP/1.3\r\n\r\n";
693 // HttpMethod::Go - Run a single loop /*{{{*/
694 // ---------------------------------------------------------------------
695 /* This runs the select loop over the server FDs, Output file FDs and
697 bool HttpMethod::Go(bool ToFile
,ServerState
*Srv
)
699 // Server has closed the connection
700 if (Srv
->ServerFd
== -1 && (Srv
->In
.WriteSpace() == false ||
708 /* Add the server. We only send more requests if the connection will
710 if (Srv
->Out
.WriteSpace() == true && Srv
->ServerFd
!= -1
711 && Srv
->Persistent
== true)
712 FD_SET(Srv
->ServerFd
,&wfds
);
713 if (Srv
->In
.ReadSpace() == true && Srv
->ServerFd
!= -1)
714 FD_SET(Srv
->ServerFd
,&rfds
);
721 if (Srv
->In
.WriteSpace() == true && ToFile
== true && FileFD
!= -1)
722 FD_SET(FileFD
,&wfds
);
725 FD_SET(STDIN_FILENO
,&rfds
);
727 // Figure out the max fd
729 if (MaxFd
< Srv
->ServerFd
)
730 MaxFd
= Srv
->ServerFd
;
737 if ((Res
= select(MaxFd
+1,&rfds
,&wfds
,0,&tv
)) < 0)
741 return _error
->Errno("select",_("Select failed"));
746 _error
->Error(_("Connection timed out"));
747 return ServerDie(Srv
);
751 if (Srv
->ServerFd
!= -1 && FD_ISSET(Srv
->ServerFd
,&rfds
))
754 if (Srv
->In
.Read(Srv
->ServerFd
) == false)
755 return ServerDie(Srv
);
758 if (Srv
->ServerFd
!= -1 && FD_ISSET(Srv
->ServerFd
,&wfds
))
761 if (Srv
->Out
.Write(Srv
->ServerFd
) == false)
762 return ServerDie(Srv
);
765 // Send data to the file
766 if (FileFD
!= -1 && FD_ISSET(FileFD
,&wfds
))
768 if (Srv
->In
.Write(FileFD
) == false)
769 return _error
->Errno("write",_("Error writing to output file"));
772 // Handle commands from APT
773 if (FD_ISSET(STDIN_FILENO
,&rfds
))
782 // HttpMethod::Flush - Dump the buffer into the file /*{{{*/
783 // ---------------------------------------------------------------------
784 /* This takes the current input buffer from the Server FD and writes it
786 bool HttpMethod::Flush(ServerState
*Srv
)
790 SetNonBlock(File
->Fd(),false);
791 if (Srv
->In
.WriteSpace() == false)
794 while (Srv
->In
.WriteSpace() == true)
796 if (Srv
->In
.Write(File
->Fd()) == false)
797 return _error
->Errno("write",_("Error writing to file"));
798 if (Srv
->In
.IsLimit() == true)
802 if (Srv
->In
.IsLimit() == true || Srv
->Encoding
== ServerState::Closes
)
808 // HttpMethod::ServerDie - The server has closed the connection. /*{{{*/
809 // ---------------------------------------------------------------------
811 bool HttpMethod::ServerDie(ServerState
*Srv
)
813 unsigned int LErrno
= errno
;
815 // Dump the buffer to the file
816 if (Srv
->State
== ServerState::Data
)
818 SetNonBlock(File
->Fd(),false);
819 while (Srv
->In
.WriteSpace() == true)
821 if (Srv
->In
.Write(File
->Fd()) == false)
822 return _error
->Errno("write",_("Error writing to the file"));
825 if (Srv
->In
.IsLimit() == true)
830 // See if this is because the server finished the data stream
831 if (Srv
->In
.IsLimit() == false && Srv
->State
!= ServerState::Header
&&
832 Srv
->Encoding
!= ServerState::Closes
)
836 return _error
->Error(_("Error reading from server. Remote end closed connection"));
838 return _error
->Errno("read",_("Error reading from server"));
844 // Nothing left in the buffer
845 if (Srv
->In
.WriteSpace() == false)
848 // We may have got multiple responses back in one packet..
856 // HttpMethod::DealWithHeaders - Handle the retrieved header data /*{{{*/
857 // ---------------------------------------------------------------------
858 /* We look at the header data we got back from the server and decide what
862 3 - Unrecoverable error
863 4 - Error with error content page
864 5 - Unrecoverable non-server error (close the connection) */
865 int HttpMethod::DealWithHeaders(FetchResult
&Res
,ServerState
*Srv
)
868 if (Srv
->Result
== 304)
870 unlink(Queue
->DestFile
.c_str());
872 Res
.LastModified
= Queue
->LastModified
;
876 /* We have a reply we dont handle. This should indicate a perm server
878 if (Srv
->Result
< 200 || Srv
->Result
>= 300)
880 _error
->Error("%u %s",Srv
->Result
,Srv
->Code
);
881 if (Srv
->HaveContent
== true)
886 // This is some sort of 2xx 'data follows' reply
887 Res
.LastModified
= Srv
->Date
;
888 Res
.Size
= Srv
->Size
;
892 File
= new FileFd(Queue
->DestFile
,FileFd::WriteAny
);
893 if (_error
->PendingError() == true)
896 FailFile
= Queue
->DestFile
;
897 FailFile
.c_str(); // Make sure we dont do a malloc in the signal handler
899 FailTime
= Srv
->Date
;
901 // Set the expected size
902 if (Srv
->StartPos
>= 0)
904 Res
.ResumePoint
= Srv
->StartPos
;
905 ftruncate(File
->Fd(),Srv
->StartPos
);
908 // Set the start point
909 lseek(File
->Fd(),0,SEEK_END
);
912 Srv
->In
.Hash
= new Hashes
;
914 // Fill the Hash if the file is non-empty (resume)
915 if (Srv
->StartPos
> 0)
917 lseek(File
->Fd(),0,SEEK_SET
);
918 if (Srv
->In
.Hash
->AddFD(File
->Fd(),Srv
->StartPos
) == false)
920 _error
->Errno("read",_("Problem hashing file"));
923 lseek(File
->Fd(),0,SEEK_END
);
926 SetNonBlock(File
->Fd(),true);
930 // HttpMethod::SigTerm - Handle a fatal signal /*{{{*/
931 // ---------------------------------------------------------------------
932 /* This closes and timestamps the open file. This is neccessary to get
933 resume behavoir on user abort */
934 void HttpMethod::SigTerm(int)
942 UBuf
.actime
= FailTime
;
943 UBuf
.modtime
= FailTime
;
944 utime(FailFile
.c_str(),&UBuf
);
949 // HttpMethod::Fetch - Fetch an item /*{{{*/
950 // ---------------------------------------------------------------------
951 /* This adds an item to the pipeline. We keep the pipeline at a fixed
953 bool HttpMethod::Fetch(FetchItem
*)
958 // Queue the requests
961 for (FetchItem
*I
= Queue
; I
!= 0 && Depth
< (signed)PipelineDepth
;
962 I
= I
->Next
, Depth
++)
964 // If pipelining is disabled, we only queue 1 request
965 if (Server
->Pipeline
== false && Depth
>= 0)
968 // Make sure we stick with the same server
969 if (Server
->Comp(I
->Uri
) == false)
976 SendReq(I
,Server
->Out
);
984 // HttpMethod::Configuration - Handle a configuration message /*{{{*/
985 // ---------------------------------------------------------------------
986 /* We stash the desired pipeline depth */
987 bool HttpMethod::Configuration(string Message
)
989 if (pkgAcqMethod::Configuration(Message
) == false)
992 TimeOut
= _config
->FindI("Acquire::http::Timeout",TimeOut
);
993 PipelineDepth
= _config
->FindI("Acquire::http::Pipeline-Depth",
995 Debug
= _config
->FindB("Debug::Acquire::http",false);
1000 // HttpMethod::Loop - Main loop /*{{{*/
1001 // ---------------------------------------------------------------------
1003 int HttpMethod::Loop()
1005 signal(SIGTERM
,SigTerm
);
1006 signal(SIGINT
,SigTerm
);
1010 int FailCounter
= 0;
1013 // We have no commands, wait for some to arrive
1016 if (WaitFd(STDIN_FILENO
) == false)
1020 /* Run messages, we can accept 0 (no message) if we didn't
1021 do a WaitFd above.. Otherwise the FD is closed. */
1022 int Result
= Run(true);
1023 if (Result
!= -1 && (Result
!= 0 || Queue
== 0))
1029 // Connect to the server
1030 if (Server
== 0 || Server
->Comp(Queue
->Uri
) == false)
1033 Server
= new ServerState(Queue
->Uri
,this);
1036 /* If the server has explicitly said this is the last connection
1037 then we pre-emptively shut down the pipeline and tear down
1038 the connection. This will speed up HTTP/1.0 servers a tad
1039 since we don't have to wait for the close sequence to
1041 if (Server
->Persistent
== false)
1044 // Reset the pipeline
1045 if (Server
->ServerFd
== -1)
1048 // Connnect to the host
1049 if (Server
->Open() == false)
1057 // Fill the pipeline.
1060 // Fetch the next URL header data from the server.
1061 switch (Server
->RunHeaders())
1066 // The header data is bad
1069 _error
->Error(_("Bad header data"));
1075 // The server closed a connection during the header get..
1082 Server
->Pipeline
= false;
1084 if (FailCounter
>= 2)
1086 Fail(_("Connection failed"),true);
1095 // Decide what to do.
1097 Res
.Filename
= Queue
->DestFile
;
1098 switch (DealWithHeaders(Res
,Server
))
1100 // Ok, the file is Open
1106 bool Result
= Server
->RunData();
1108 /* If the server is sending back sizeless responses then fill in
1111 Res
.Size
= File
->Size();
1113 // Close the file, destroy the FD object and timestamp it
1119 struct utimbuf UBuf
;
1121 UBuf
.actime
= Server
->Date
;
1122 UBuf
.modtime
= Server
->Date
;
1123 utime(Queue
->DestFile
.c_str(),&UBuf
);
1125 // Send status to APT
1128 Res
.TakeHashes(*Server
->In
.Hash
);
1144 // Hard server error, not found or something
1151 // Hard internal error, kill the connection and fail
1163 // We need to flush the data, the header is like a 404 w/ error text
1168 // Send to content to dev/null
1169 File
= new FileFd("/dev/null",FileFd::WriteExists
);
1177 Fail(_("Internal error"));
1190 setlocale(LC_ALL
, "");