]>
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;
62 // CircleBuf::CircleBuf - Circular input buffer /*{{{*/
63 // ---------------------------------------------------------------------
65 CircleBuf::CircleBuf(unsigned long Size
) : Size(Size
), Hash(0)
67 Buf
= new unsigned char[Size
];
71 // CircleBuf::Reset - Reset to the default state /*{{{*/
72 // ---------------------------------------------------------------------
74 void CircleBuf::Reset()
79 MaxGet
= (unsigned int)-1;
88 // CircleBuf::Read - Read from a FD into the circular buffer /*{{{*/
89 // ---------------------------------------------------------------------
90 /* This fills up the buffer with as much data as is in the FD, assuming it
92 bool CircleBuf::Read(int Fd
)
96 // Woops, buffer is full
97 if (InP
- OutP
== Size
)
100 // Write the buffer segment
102 Res
= read(Fd
,Buf
+ (InP%Size
),LeftRead());
114 gettimeofday(&Start
,0);
119 // CircleBuf::Read - Put the string into the buffer /*{{{*/
120 // ---------------------------------------------------------------------
121 /* This will hold the string in and fill the buffer with it as it empties */
122 bool CircleBuf::Read(string Data
)
129 // CircleBuf::FillOut - Fill the buffer from the output queue /*{{{*/
130 // ---------------------------------------------------------------------
132 void CircleBuf::FillOut()
134 if (OutQueue
.empty() == true)
138 // Woops, buffer is full
139 if (InP
- OutP
== Size
)
142 // Write the buffer segment
143 unsigned long Sz
= LeftRead();
144 if (OutQueue
.length() - StrPos
< Sz
)
145 Sz
= OutQueue
.length() - StrPos
;
146 memcpy(Buf
+ (InP%Size
),OutQueue
.c_str() + StrPos
,Sz
);
151 if (OutQueue
.length() == StrPos
)
160 // CircleBuf::Write - Write from the buffer into a FD /*{{{*/
161 // ---------------------------------------------------------------------
162 /* This empties the buffer into the FD. */
163 bool CircleBuf::Write(int Fd
)
169 // Woops, buffer is empty
176 // Write the buffer segment
178 Res
= write(Fd
,Buf
+ (OutP%Size
),LeftWrite());
191 Hash
->Add(Buf
+ (OutP%Size
),Res
);
197 // CircleBuf::WriteTillEl - Write from the buffer to a string /*{{{*/
198 // ---------------------------------------------------------------------
199 /* This copies till the first empty line */
200 bool CircleBuf::WriteTillEl(string
&Data
,bool Single
)
202 // We cheat and assume it is unneeded to have more than one buffer load
203 for (unsigned long I
= OutP
; I
< InP
; I
++)
205 if (Buf
[I%Size
] != '\n')
208 if (I
< InP
&& Buf
[I%Size
] == '\r')
213 if (Buf
[I%Size
] != '\n')
216 if (I
< InP
&& Buf
[I%Size
] == '\r')
226 unsigned long Sz
= LeftWrite();
229 if (I
- OutP
< LeftWrite())
231 Data
+= string((char *)(Buf
+ (OutP%Size
)),Sz
);
239 // CircleBuf::Stats - Print out stats information /*{{{*/
240 // ---------------------------------------------------------------------
242 void CircleBuf::Stats()
248 gettimeofday(&Stop
,0);
249 /* float Diff = Stop.tv_sec - Start.tv_sec +
250 (float)(Stop.tv_usec - Start.tv_usec)/1000000;
251 clog << "Got " << InP << " in " << Diff << " at " << InP/Diff << endl;*/
255 // ServerState::ServerState - Constructor /*{{{*/
256 // ---------------------------------------------------------------------
258 ServerState::ServerState(URI Srv
,HttpMethod
*Owner
) : Owner(Owner
),
259 In(64*1024), Out(4*1024),
265 // ServerState::Open - Open a connection to the server /*{{{*/
266 // ---------------------------------------------------------------------
267 /* This opens a connection to the server. */
268 bool ServerState::Open()
270 // Use the already open connection if possible.
279 // Determine the proxy setting
280 if (getenv("http_proxy") == 0)
282 string DefProxy
= _config
->Find("Acquire::http::Proxy");
283 string SpecificProxy
= _config
->Find("Acquire::http::Proxy::" + ServerName
.Host
);
284 if (SpecificProxy
.empty() == false)
286 if (SpecificProxy
== "DIRECT")
289 Proxy
= SpecificProxy
;
295 Proxy
= getenv("http_proxy");
297 // Parse no_proxy, a , separated list of domains
298 if (getenv("no_proxy") != 0)
300 if (CheckDomainList(ServerName
.Host
,getenv("no_proxy")) == true)
304 // Determine what host and port to use based on the proxy settings
307 if (Proxy
.empty() == true || Proxy
.Host
.empty() == true)
309 if (ServerName
.Port
!= 0)
310 Port
= ServerName
.Port
;
311 Host
= ServerName
.Host
;
320 // Connect to the remote server
321 if (Connect(Host
,Port
,"http",80,ServerFd
,TimeOut
,Owner
) == false)
327 // ServerState::Close - Close a connection to the server /*{{{*/
328 // ---------------------------------------------------------------------
330 bool ServerState::Close()
337 // ServerState::RunHeaders - Get the headers before the data /*{{{*/
338 // ---------------------------------------------------------------------
339 /* Returns 0 if things are OK, 1 if an IO error occursed and 2 if a header
340 parse error occured */
341 int ServerState::RunHeaders()
345 Owner
->Status(_("Waiting for headers"));
359 if (In
.WriteTillEl(Data
) == false)
365 for (string::const_iterator I
= Data
.begin(); I
< Data
.end(); I
++)
367 string::const_iterator J
= I
;
368 for (; J
!= Data
.end() && *J
!= '\n' && *J
!= '\r';J
++);
369 if (HeaderLine(string(I
,J
)) == false)
374 // 100 Continue is a Nop...
378 // Tidy up the connection persistance state.
379 if (Encoding
== Closes
&& HaveContent
== true)
384 while (Owner
->Go(false,this) == true);
389 // ServerState::RunData - Transfer the data from the socket /*{{{*/
390 // ---------------------------------------------------------------------
392 bool ServerState::RunData()
396 // Chunked transfer encoding is fun..
397 if (Encoding
== Chunked
)
401 // Grab the block size
407 if (In
.WriteTillEl(Data
,true) == true)
410 while ((Last
= Owner
->Go(false,this)) == true);
415 // See if we are done
416 unsigned long Len
= strtol(Data
.c_str(),0,16);
421 // We have to remove the entity trailer
425 if (In
.WriteTillEl(Data
,true) == true && Data
.length() <= 2)
428 while ((Last
= Owner
->Go(false,this)) == true);
431 return !_error
->PendingError();
434 // Transfer the block
436 while (Owner
->Go(true,this) == true)
437 if (In
.IsLimit() == true)
441 if (In
.IsLimit() == false)
444 // The server sends an extra new line before the next block specifier..
449 if (In
.WriteTillEl(Data
,true) == true)
452 while ((Last
= Owner
->Go(false,this)) == true);
459 /* Closes encoding is used when the server did not specify a size, the
460 loss of the connection means we are done */
461 if (Encoding
== Closes
)
464 In
.Limit(Size
- StartPos
);
466 // Just transfer the whole block.
469 if (In
.IsLimit() == false)
473 return !_error
->PendingError();
475 while (Owner
->Go(true,this) == true);
478 return Owner
->Flush(this) && !_error
->PendingError();
481 // ServerState::HeaderLine - Process a header line /*{{{*/
482 // ---------------------------------------------------------------------
484 bool ServerState::HeaderLine(string Line
)
486 if (Line
.empty() == true)
489 // The http server might be trying to do something evil.
490 if (Line
.length() >= MAXLEN
)
491 return _error
->Error(_("Got a single header line over %u chars"),MAXLEN
);
493 string::size_type Pos
= Line
.find(' ');
494 if (Pos
== string::npos
|| Pos
+1 > Line
.length())
496 // Blah, some servers use "connection:closes", evil.
497 Pos
= Line
.find(':');
498 if (Pos
== string::npos
|| Pos
+ 2 > Line
.length())
499 return _error
->Error(_("Bad header line"));
503 // Parse off any trailing spaces between the : and the next word.
504 string::size_type Pos2
= Pos
;
505 while (Pos2
< Line
.length() && isspace(Line
[Pos2
]) != 0)
508 string Tag
= string(Line
,0,Pos
);
509 string Val
= string(Line
,Pos2
);
511 if (stringcasecmp(Tag
.c_str(),Tag
.c_str()+4,"HTTP") == 0)
513 // Evil servers return no version
516 if (sscanf(Line
.c_str(),"HTTP/%u.%u %u %[^\n]",&Major
,&Minor
,
518 return _error
->Error(_("The HTTP server sent an invalid reply header"));
524 if (sscanf(Line
.c_str(),"HTTP %u %[^\n]",&Result
,Code
) != 2)
525 return _error
->Error(_("The HTTP server sent an invalid reply header"));
528 /* Check the HTTP response header to get the default persistance
534 if (Major
== 1 && Minor
<= 0)
543 if (stringcasecmp(Tag
,"Content-Length:") == 0)
545 if (Encoding
== Closes
)
549 // The length is already set from the Content-Range header
553 if (sscanf(Val
.c_str(),"%lu",&Size
) != 1)
554 return _error
->Error(_("The HTTP server sent an invalid Content-Length header"));
558 if (stringcasecmp(Tag
,"Content-Type:") == 0)
564 if (stringcasecmp(Tag
,"Content-Range:") == 0)
568 if (sscanf(Val
.c_str(),"bytes %lu-%*u/%lu",&StartPos
,&Size
) != 2)
569 return _error
->Error(_("The HTTP server sent an invalid Content-Range header"));
570 if ((unsigned)StartPos
> Size
)
571 return _error
->Error(_("This HTTP server has broken range support"));
575 if (stringcasecmp(Tag
,"Transfer-Encoding:") == 0)
578 if (stringcasecmp(Val
,"chunked") == 0)
583 if (stringcasecmp(Tag
,"Connection:") == 0)
585 if (stringcasecmp(Val
,"close") == 0)
587 if (stringcasecmp(Val
,"keep-alive") == 0)
592 if (stringcasecmp(Tag
,"Last-Modified:") == 0)
594 if (StrToTime(Val
,Date
) == false)
595 return _error
->Error(_("Unknown date format"));
603 // HttpMethod::SendReq - Send the HTTP request /*{{{*/
604 // ---------------------------------------------------------------------
605 /* This places the http request in the outbound buffer */
606 void HttpMethod::SendReq(FetchItem
*Itm
,CircleBuf
&Out
)
610 // The HTTP server expects a hostname with a trailing :port
612 string ProperHost
= Uri
.Host
;
615 sprintf(Buf
,":%u",Uri
.Port
);
620 if (Itm
->Uri
.length() >= sizeof(Buf
))
623 /* Build the request. We include a keep-alive header only for non-proxy
624 requests. This is to tweak old http/1.0 servers that do support keep-alive
625 but not HTTP/1.1 automatic keep-alive. Doing this with a proxy server
626 will glitch HTTP/1.0 proxies because they do not filter it out and
627 pass it on, HTTP/1.1 says the connection should default to keep alive
628 and we expect the proxy to do this */
629 if (Proxy
.empty() == true)
630 sprintf(Buf
,"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n",
631 QuoteString(Uri
.Path
,"~").c_str(),ProperHost
.c_str());
634 /* Generate a cache control header if necessary. We place a max
635 cache age on index files, optionally set a no-cache directive
636 and a no-store directive for archives. */
637 sprintf(Buf
,"GET %s HTTP/1.1\r\nHost: %s\r\n",
638 Itm
->Uri
.c_str(),ProperHost
.c_str());
639 // only generate a cache control header if we actually want to
641 if (_config
->FindB("Acquire::http::No-Cache",false) == false)
643 if (Itm
->IndexFile
== true)
644 sprintf(Buf
+strlen(Buf
),"Cache-Control: max-age=%u\r\n",
645 _config
->FindI("Acquire::http::Max-Age",0));
648 if (_config
->FindB("Acquire::http::No-Store",false) == true)
649 strcat(Buf
,"Cache-Control: no-store\r\n");
653 // generate a no-cache header if needed
654 if (_config
->FindB("Acquire::http::No-Cache",false) == true)
655 strcat(Buf
,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
660 // Check for a partial file
662 if (stat(Itm
->DestFile
.c_str(),&SBuf
) >= 0 && SBuf
.st_size
> 0)
664 // In this case we send an if-range query with a range header
665 sprintf(Buf
,"Range: bytes=%li-\r\nIf-Range: %s\r\n",(long)SBuf
.st_size
- 1,
666 TimeRFC1123(SBuf
.st_mtime
).c_str());
671 if (Itm
->LastModified
!= 0)
673 sprintf(Buf
,"If-Modified-Since: %s\r\n",TimeRFC1123(Itm
->LastModified
).c_str());
678 if (Proxy
.User
.empty() == false || Proxy
.Password
.empty() == false)
679 Req
+= string("Proxy-Authorization: Basic ") +
680 Base64Encode(Proxy
.User
+ ":" + Proxy
.Password
) + "\r\n";
682 if (Uri
.User
.empty() == false || Uri
.Password
.empty() == false)
683 Req
+= string("Authorization: Basic ") +
684 Base64Encode(Uri
.User
+ ":" + Uri
.Password
) + "\r\n";
686 Req
+= "User-Agent: Debian APT-HTTP/1.3\r\n\r\n";
694 // HttpMethod::Go - Run a single loop /*{{{*/
695 // ---------------------------------------------------------------------
696 /* This runs the select loop over the server FDs, Output file FDs and
698 bool HttpMethod::Go(bool ToFile
,ServerState
*Srv
)
700 // Server has closed the connection
701 if (Srv
->ServerFd
== -1 && (Srv
->In
.WriteSpace() == false ||
709 /* Add the server. We only send more requests if the connection will
711 if (Srv
->Out
.WriteSpace() == true && Srv
->ServerFd
!= -1
712 && Srv
->Persistent
== true)
713 FD_SET(Srv
->ServerFd
,&wfds
);
714 if (Srv
->In
.ReadSpace() == true && Srv
->ServerFd
!= -1)
715 FD_SET(Srv
->ServerFd
,&rfds
);
722 if (Srv
->In
.WriteSpace() == true && ToFile
== true && FileFD
!= -1)
723 FD_SET(FileFD
,&wfds
);
726 FD_SET(STDIN_FILENO
,&rfds
);
728 // Figure out the max fd
730 if (MaxFd
< Srv
->ServerFd
)
731 MaxFd
= Srv
->ServerFd
;
738 if ((Res
= select(MaxFd
+1,&rfds
,&wfds
,0,&tv
)) < 0)
742 return _error
->Errno("select",_("Select failed"));
747 _error
->Error(_("Connection timed out"));
748 return ServerDie(Srv
);
752 if (Srv
->ServerFd
!= -1 && FD_ISSET(Srv
->ServerFd
,&rfds
))
755 if (Srv
->In
.Read(Srv
->ServerFd
) == false)
756 return ServerDie(Srv
);
759 if (Srv
->ServerFd
!= -1 && FD_ISSET(Srv
->ServerFd
,&wfds
))
762 if (Srv
->Out
.Write(Srv
->ServerFd
) == false)
763 return ServerDie(Srv
);
766 // Send data to the file
767 if (FileFD
!= -1 && FD_ISSET(FileFD
,&wfds
))
769 if (Srv
->In
.Write(FileFD
) == false)
770 return _error
->Errno("write",_("Error writing to output file"));
773 // Handle commands from APT
774 if (FD_ISSET(STDIN_FILENO
,&rfds
))
783 // HttpMethod::Flush - Dump the buffer into the file /*{{{*/
784 // ---------------------------------------------------------------------
785 /* This takes the current input buffer from the Server FD and writes it
787 bool HttpMethod::Flush(ServerState
*Srv
)
791 SetNonBlock(File
->Fd(),false);
792 if (Srv
->In
.WriteSpace() == false)
795 while (Srv
->In
.WriteSpace() == true)
797 if (Srv
->In
.Write(File
->Fd()) == false)
798 return _error
->Errno("write",_("Error writing to file"));
799 if (Srv
->In
.IsLimit() == true)
803 if (Srv
->In
.IsLimit() == true || Srv
->Encoding
== ServerState::Closes
)
809 // HttpMethod::ServerDie - The server has closed the connection. /*{{{*/
810 // ---------------------------------------------------------------------
812 bool HttpMethod::ServerDie(ServerState
*Srv
)
814 unsigned int LErrno
= errno
;
816 // Dump the buffer to the file
817 if (Srv
->State
== ServerState::Data
)
819 SetNonBlock(File
->Fd(),false);
820 while (Srv
->In
.WriteSpace() == true)
822 if (Srv
->In
.Write(File
->Fd()) == false)
823 return _error
->Errno("write",_("Error writing to the file"));
826 if (Srv
->In
.IsLimit() == true)
831 // See if this is because the server finished the data stream
832 if (Srv
->In
.IsLimit() == false && Srv
->State
!= ServerState::Header
&&
833 Srv
->Encoding
!= ServerState::Closes
)
837 return _error
->Error(_("Error reading from server. Remote end closed connection"));
839 return _error
->Errno("read",_("Error reading from server"));
845 // Nothing left in the buffer
846 if (Srv
->In
.WriteSpace() == false)
849 // We may have got multiple responses back in one packet..
857 // HttpMethod::DealWithHeaders - Handle the retrieved header data /*{{{*/
858 // ---------------------------------------------------------------------
859 /* We look at the header data we got back from the server and decide what
863 3 - Unrecoverable error
864 4 - Error with error content page
865 5 - Unrecoverable non-server error (close the connection) */
866 int HttpMethod::DealWithHeaders(FetchResult
&Res
,ServerState
*Srv
)
869 if (Srv
->Result
== 304)
871 unlink(Queue
->DestFile
.c_str());
873 Res
.LastModified
= Queue
->LastModified
;
877 /* We have a reply we dont handle. This should indicate a perm server
879 if (Srv
->Result
< 200 || Srv
->Result
>= 300)
881 _error
->Error("%u %s",Srv
->Result
,Srv
->Code
);
882 if (Srv
->HaveContent
== true)
887 // This is some sort of 2xx 'data follows' reply
888 Res
.LastModified
= Srv
->Date
;
889 Res
.Size
= Srv
->Size
;
893 File
= new FileFd(Queue
->DestFile
,FileFd::WriteAny
);
894 if (_error
->PendingError() == true)
897 FailFile
= Queue
->DestFile
;
898 FailFile
.c_str(); // Make sure we dont do a malloc in the signal handler
900 FailTime
= Srv
->Date
;
902 // Set the expected size
903 if (Srv
->StartPos
>= 0)
905 Res
.ResumePoint
= Srv
->StartPos
;
906 ftruncate(File
->Fd(),Srv
->StartPos
);
909 // Set the start point
910 lseek(File
->Fd(),0,SEEK_END
);
913 Srv
->In
.Hash
= new Hashes
;
915 // Fill the Hash if the file is non-empty (resume)
916 if (Srv
->StartPos
> 0)
918 lseek(File
->Fd(),0,SEEK_SET
);
919 if (Srv
->In
.Hash
->AddFD(File
->Fd(),Srv
->StartPos
) == false)
921 _error
->Errno("read",_("Problem hashing file"));
924 lseek(File
->Fd(),0,SEEK_END
);
927 SetNonBlock(File
->Fd(),true);
931 // HttpMethod::SigTerm - Handle a fatal signal /*{{{*/
932 // ---------------------------------------------------------------------
933 /* This closes and timestamps the open file. This is neccessary to get
934 resume behavoir on user abort */
935 void HttpMethod::SigTerm(int)
943 UBuf
.actime
= FailTime
;
944 UBuf
.modtime
= FailTime
;
945 utime(FailFile
.c_str(),&UBuf
);
950 // HttpMethod::Fetch - Fetch an item /*{{{*/
951 // ---------------------------------------------------------------------
952 /* This adds an item to the pipeline. We keep the pipeline at a fixed
954 bool HttpMethod::Fetch(FetchItem
*)
959 // Queue the requests
962 for (FetchItem
*I
= Queue
; I
!= 0 && Depth
< (signed)PipelineDepth
;
963 I
= I
->Next
, Depth
++)
965 // If pipelining is disabled, we only queue 1 request
966 if (Server
->Pipeline
== false && Depth
>= 0)
969 // Make sure we stick with the same server
970 if (Server
->Comp(I
->Uri
) == false)
977 SendReq(I
,Server
->Out
);
985 // HttpMethod::Configuration - Handle a configuration message /*{{{*/
986 // ---------------------------------------------------------------------
987 /* We stash the desired pipeline depth */
988 bool HttpMethod::Configuration(string Message
)
990 if (pkgAcqMethod::Configuration(Message
) == false)
993 TimeOut
= _config
->FindI("Acquire::http::Timeout",TimeOut
);
994 PipelineDepth
= _config
->FindI("Acquire::http::Pipeline-Depth",
996 Debug
= _config
->FindB("Debug::Acquire::http",false);
1001 // HttpMethod::Loop - Main loop /*{{{*/
1002 // ---------------------------------------------------------------------
1004 int HttpMethod::Loop()
1006 signal(SIGTERM
,SigTerm
);
1007 signal(SIGINT
,SigTerm
);
1011 int FailCounter
= 0;
1014 // We have no commands, wait for some to arrive
1017 if (WaitFd(STDIN_FILENO
) == false)
1021 /* Run messages, we can accept 0 (no message) if we didn't
1022 do a WaitFd above.. Otherwise the FD is closed. */
1023 int Result
= Run(true);
1024 if (Result
!= -1 && (Result
!= 0 || Queue
== 0))
1030 // Connect to the server
1031 if (Server
== 0 || Server
->Comp(Queue
->Uri
) == false)
1034 Server
= new ServerState(Queue
->Uri
,this);
1037 /* If the server has explicitly said this is the last connection
1038 then we pre-emptively shut down the pipeline and tear down
1039 the connection. This will speed up HTTP/1.0 servers a tad
1040 since we don't have to wait for the close sequence to
1042 if (Server
->Persistent
== false)
1045 // Reset the pipeline
1046 if (Server
->ServerFd
== -1)
1049 // Connnect to the host
1050 if (Server
->Open() == false)
1058 // Fill the pipeline.
1061 // Fetch the next URL header data from the server.
1062 switch (Server
->RunHeaders())
1067 // The header data is bad
1070 _error
->Error(_("Bad header data"));
1076 // The server closed a connection during the header get..
1083 Server
->Pipeline
= false;
1085 if (FailCounter
>= 2)
1087 Fail(_("Connection failed"),true);
1096 // Decide what to do.
1098 Res
.Filename
= Queue
->DestFile
;
1099 switch (DealWithHeaders(Res
,Server
))
1101 // Ok, the file is Open
1107 bool Result
= Server
->RunData();
1109 /* If the server is sending back sizeless responses then fill in
1112 Res
.Size
= File
->Size();
1114 // Close the file, destroy the FD object and timestamp it
1120 struct utimbuf UBuf
;
1122 UBuf
.actime
= Server
->Date
;
1123 UBuf
.modtime
= Server
->Date
;
1124 utime(Queue
->DestFile
.c_str(),&UBuf
);
1126 // Send status to APT
1129 Res
.TakeHashes(*Server
->In
.Hash
);
1145 // Hard server error, not found or something
1152 // Hard internal error, kill the connection and fail
1164 // We need to flush the data, the header is like a 404 w/ error text
1169 // Send to content to dev/null
1170 File
= new FileFd("/dev/null",FileFd::WriteExists
);
1178 Fail(_("Internal error"));
1191 setlocale(LC_ALL
, "");