]>
git.saurik.com Git - apt.git/blob - methods/http.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: http.cc,v 1.54 2002/04/18 05:09:38 jgg 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>
47 #include "rfc2553emu.h"
53 string
HttpMethod::FailFile
;
54 int HttpMethod::FailFd
= -1;
55 time_t HttpMethod::FailTime
= 0;
56 unsigned long PipelineDepth
= 10;
57 unsigned long TimeOut
= 120;
60 // CircleBuf::CircleBuf - Circular input buffer /*{{{*/
61 // ---------------------------------------------------------------------
63 CircleBuf::CircleBuf(unsigned long Size
) : Size(Size
), Hash(0)
65 Buf
= new unsigned char[Size
];
69 // CircleBuf::Reset - Reset to the default state /*{{{*/
70 // ---------------------------------------------------------------------
72 void CircleBuf::Reset()
77 MaxGet
= (unsigned int)-1;
86 // CircleBuf::Read - Read from a FD into the circular buffer /*{{{*/
87 // ---------------------------------------------------------------------
88 /* This fills up the buffer with as much data as is in the FD, assuming it
90 bool CircleBuf::Read(int Fd
)
94 // Woops, buffer is full
95 if (InP
- OutP
== Size
)
98 // Write the buffer segment
100 Res
= read(Fd
,Buf
+ (InP%Size
),LeftRead());
112 gettimeofday(&Start
,0);
117 // CircleBuf::Read - Put the string into the buffer /*{{{*/
118 // ---------------------------------------------------------------------
119 /* This will hold the string in and fill the buffer with it as it empties */
120 bool CircleBuf::Read(string Data
)
127 // CircleBuf::FillOut - Fill the buffer from the output queue /*{{{*/
128 // ---------------------------------------------------------------------
130 void CircleBuf::FillOut()
132 if (OutQueue
.empty() == true)
136 // Woops, buffer is full
137 if (InP
- OutP
== Size
)
140 // Write the buffer segment
141 unsigned long Sz
= LeftRead();
142 if (OutQueue
.length() - StrPos
< Sz
)
143 Sz
= OutQueue
.length() - StrPos
;
144 memcpy(Buf
+ (InP%Size
),OutQueue
.c_str() + StrPos
,Sz
);
149 if (OutQueue
.length() == StrPos
)
158 // CircleBuf::Write - Write from the buffer into a FD /*{{{*/
159 // ---------------------------------------------------------------------
160 /* This empties the buffer into the FD. */
161 bool CircleBuf::Write(int Fd
)
167 // Woops, buffer is empty
174 // Write the buffer segment
176 Res
= write(Fd
,Buf
+ (OutP%Size
),LeftWrite());
189 Hash
->Add(Buf
+ (OutP%Size
),Res
);
195 // CircleBuf::WriteTillEl - Write from the buffer to a string /*{{{*/
196 // ---------------------------------------------------------------------
197 /* This copies till the first empty line */
198 bool CircleBuf::WriteTillEl(string
&Data
,bool Single
)
200 // We cheat and assume it is unneeded to have more than one buffer load
201 for (unsigned long I
= OutP
; I
< InP
; I
++)
203 if (Buf
[I%Size
] != '\n')
205 for (I
++; I
< InP
&& Buf
[I%Size
] == '\r'; I
++);
209 if (Buf
[I%Size
] != '\n')
211 for (I
++; I
< InP
&& Buf
[I%Size
] == '\r'; I
++);
220 unsigned long Sz
= LeftWrite();
223 if (I
- OutP
< LeftWrite())
225 Data
+= string((char *)(Buf
+ (OutP%Size
)),Sz
);
233 // CircleBuf::Stats - Print out stats information /*{{{*/
234 // ---------------------------------------------------------------------
236 void CircleBuf::Stats()
242 gettimeofday(&Stop
,0);
243 /* float Diff = Stop.tv_sec - Start.tv_sec +
244 (float)(Stop.tv_usec - Start.tv_usec)/1000000;
245 clog << "Got " << InP << " in " << Diff << " at " << InP/Diff << endl;*/
249 // ServerState::ServerState - Constructor /*{{{*/
250 // ---------------------------------------------------------------------
252 ServerState::ServerState(URI Srv
,HttpMethod
*Owner
) : Owner(Owner
),
253 In(64*1024), Out(4*1024),
259 // ServerState::Open - Open a connection to the server /*{{{*/
260 // ---------------------------------------------------------------------
261 /* This opens a connection to the server. */
262 bool ServerState::Open()
264 // Use the already open connection if possible.
273 // Determine the proxy setting
274 if (getenv("http_proxy") == 0)
276 string DefProxy
= _config
->Find("Acquire::http::Proxy");
277 string SpecificProxy
= _config
->Find("Acquire::http::Proxy::" + ServerName
.Host
);
278 if (SpecificProxy
.empty() == false)
280 if (SpecificProxy
== "DIRECT")
283 Proxy
= SpecificProxy
;
289 Proxy
= getenv("http_proxy");
291 // Parse no_proxy, a , separated list of domains
292 if (getenv("no_proxy") != 0)
294 if (CheckDomainList(ServerName
.Host
,getenv("no_proxy")) == true)
298 // Determine what host and port to use based on the proxy settings
301 if (Proxy
.empty() == true || Proxy
.Host
.empty() == true)
303 if (ServerName
.Port
!= 0)
304 Port
= ServerName
.Port
;
305 Host
= ServerName
.Host
;
314 // Connect to the remote server
315 if (Connect(Host
,Port
,"http",80,ServerFd
,TimeOut
,Owner
) == false)
321 // ServerState::Close - Close a connection to the server /*{{{*/
322 // ---------------------------------------------------------------------
324 bool ServerState::Close()
331 // ServerState::RunHeaders - Get the headers before the data /*{{{*/
332 // ---------------------------------------------------------------------
333 /* Returns 0 if things are OK, 1 if an IO error occursed and 2 if a header
334 parse error occured */
335 int ServerState::RunHeaders()
339 Owner
->Status("Waiting for file");
353 if (In
.WriteTillEl(Data
) == false)
359 for (string::const_iterator I
= Data
.begin(); I
< Data
.end(); I
++)
361 string::const_iterator J
= I
;
362 for (; J
!= Data
.end() && *J
!= '\n' && *J
!= '\r';J
++);
363 if (HeaderLine(string(I
,J
)) == false)
368 // 100 Continue is a Nop...
372 // Tidy up the connection persistance state.
373 if (Encoding
== Closes
&& HaveContent
== true)
378 while (Owner
->Go(false,this) == true);
383 // ServerState::RunData - Transfer the data from the socket /*{{{*/
384 // ---------------------------------------------------------------------
386 bool ServerState::RunData()
390 // Chunked transfer encoding is fun..
391 if (Encoding
== Chunked
)
395 // Grab the block size
401 if (In
.WriteTillEl(Data
,true) == true)
404 while ((Last
= Owner
->Go(false,this)) == true);
409 // See if we are done
410 unsigned long Len
= strtol(Data
.c_str(),0,16);
415 // We have to remove the entity trailer
419 if (In
.WriteTillEl(Data
,true) == true && Data
.length() <= 2)
422 while ((Last
= Owner
->Go(false,this)) == true);
425 return !_error
->PendingError();
428 // Transfer the block
430 while (Owner
->Go(true,this) == true)
431 if (In
.IsLimit() == true)
435 if (In
.IsLimit() == false)
438 // The server sends an extra new line before the next block specifier..
443 if (In
.WriteTillEl(Data
,true) == true)
446 while ((Last
= Owner
->Go(false,this)) == true);
453 /* Closes encoding is used when the server did not specify a size, the
454 loss of the connection means we are done */
455 if (Encoding
== Closes
)
458 In
.Limit(Size
- StartPos
);
460 // Just transfer the whole block.
463 if (In
.IsLimit() == false)
467 return !_error
->PendingError();
469 while (Owner
->Go(true,this) == true);
472 return Owner
->Flush(this) && !_error
->PendingError();
475 // ServerState::HeaderLine - Process a header line /*{{{*/
476 // ---------------------------------------------------------------------
478 bool ServerState::HeaderLine(string Line
)
480 if (Line
.empty() == true)
483 // The http server might be trying to do something evil.
484 if (Line
.length() >= MAXLEN
)
485 return _error
->Error("Got a single header line over %u chars",MAXLEN
);
487 string::size_type Pos
= Line
.find(' ');
488 if (Pos
== string::npos
|| Pos
+1 > Line
.length())
490 // Blah, some servers use "connection:closes", evil.
491 Pos
= Line
.find(':');
492 if (Pos
== string::npos
|| Pos
+ 2 > Line
.length())
493 return _error
->Error("Bad header line");
497 // Parse off any trailing spaces between the : and the next word.
498 string::size_type Pos2
= Pos
;
499 while (Pos2
< Line
.length() && isspace(Line
[Pos2
]) != 0)
502 string Tag
= string(Line
,0,Pos
);
503 string Val
= string(Line
,Pos2
);
505 if (stringcasecmp(Tag
.c_str(),Tag
.c_str()+4,"HTTP") == 0)
507 // Evil servers return no version
510 if (sscanf(Line
.c_str(),"HTTP/%u.%u %u %[^\n]",&Major
,&Minor
,
512 return _error
->Error("The http server sent an invalid reply header");
518 if (sscanf(Line
.c_str(),"HTTP %u %[^\n]",&Result
,Code
) != 2)
519 return _error
->Error("The http server sent an invalid reply header");
522 /* Check the HTTP response header to get the default persistance
528 if (Major
== 1 && Minor
<= 0)
537 if (stringcasecmp(Tag
,"Content-Length:") == 0)
539 if (Encoding
== Closes
)
543 // The length is already set from the Content-Range header
547 if (sscanf(Val
.c_str(),"%lu",&Size
) != 1)
548 return _error
->Error("The http server sent an invalid Content-Length header");
552 if (stringcasecmp(Tag
,"Content-Type:") == 0)
558 if (stringcasecmp(Tag
,"Content-Range:") == 0)
562 if (sscanf(Val
.c_str(),"bytes %lu-%*u/%lu",&StartPos
,&Size
) != 2)
563 return _error
->Error("The http server sent an invalid Content-Range header");
564 if ((unsigned)StartPos
> Size
)
565 return _error
->Error("This http server has broken range support");
569 if (stringcasecmp(Tag
,"Transfer-Encoding:") == 0)
572 if (stringcasecmp(Val
,"chunked") == 0)
577 if (stringcasecmp(Tag
,"Connection:") == 0)
579 if (stringcasecmp(Val
,"close") == 0)
581 if (stringcasecmp(Val
,"keep-alive") == 0)
586 if (stringcasecmp(Tag
,"Last-Modified:") == 0)
588 if (StrToTime(Val
,Date
) == false)
589 return _error
->Error("Unknown date format");
597 // HttpMethod::SendReq - Send the HTTP request /*{{{*/
598 // ---------------------------------------------------------------------
599 /* This places the http request in the outbound buffer */
600 void HttpMethod::SendReq(FetchItem
*Itm
,CircleBuf
&Out
)
604 // The HTTP server expects a hostname with a trailing :port
606 string ProperHost
= Uri
.Host
;
609 sprintf(Buf
,":%u",Uri
.Port
);
614 if (Itm
->Uri
.length() >= sizeof(Buf
))
617 /* Build the request. We include a keep-alive header only for non-proxy
618 requests. This is to tweak old http/1.0 servers that do support keep-alive
619 but not HTTP/1.1 automatic keep-alive. Doing this with a proxy server
620 will glitch HTTP/1.0 proxies because they do not filter it out and
621 pass it on, HTTP/1.1 says the connection should default to keep alive
622 and we expect the proxy to do this */
623 if (Proxy
.empty() == true)
624 sprintf(Buf
,"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n",
625 QuoteString(Uri
.Path
,"~").c_str(),ProperHost
.c_str());
628 /* Generate a cache control header if necessary. We place a max
629 cache age on index files, optionally set a no-cache directive
630 and a no-store directive for archives. */
631 sprintf(Buf
,"GET %s HTTP/1.1\r\nHost: %s\r\n",
632 Itm
->Uri
.c_str(),ProperHost
.c_str());
633 if (_config
->FindB("Acquire::http::No-Cache",false) == true)
634 strcat(Buf
,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
637 if (Itm
->IndexFile
== true)
638 sprintf(Buf
+strlen(Buf
),"Cache-Control: max-age=%u\r\n",
639 _config
->FindI("Acquire::http::Max-Age",60*60*24));
642 if (_config
->FindB("Acquire::http::No-Store",false) == true)
643 strcat(Buf
,"Cache-Control: no-store\r\n");
650 // Check for a partial file
652 if (stat(Itm
->DestFile
.c_str(),&SBuf
) >= 0 && SBuf
.st_size
> 0)
654 // In this case we send an if-range query with a range header
655 sprintf(Buf
,"Range: bytes=%li-\r\nIf-Range: %s\r\n",(long)SBuf
.st_size
- 1,
656 TimeRFC1123(SBuf
.st_mtime
).c_str());
661 if (Itm
->LastModified
!= 0)
663 sprintf(Buf
,"If-Modified-Since: %s\r\n",TimeRFC1123(Itm
->LastModified
).c_str());
668 if (Proxy
.User
.empty() == false || Proxy
.Password
.empty() == false)
669 Req
+= string("Proxy-Authorization: Basic ") +
670 Base64Encode(Proxy
.User
+ ":" + Proxy
.Password
) + "\r\n";
672 if (Uri
.User
.empty() == false || Uri
.Password
.empty() == false)
673 Req
+= string("Authorization: Basic ") +
674 Base64Encode(Uri
.User
+ ":" + Uri
.Password
) + "\r\n";
676 Req
+= "User-Agent: Debian APT-HTTP/1.3\r\n\r\n";
684 // HttpMethod::Go - Run a single loop /*{{{*/
685 // ---------------------------------------------------------------------
686 /* This runs the select loop over the server FDs, Output file FDs and
688 bool HttpMethod::Go(bool ToFile
,ServerState
*Srv
)
690 // Server has closed the connection
691 if (Srv
->ServerFd
== -1 && (Srv
->In
.WriteSpace() == false ||
699 /* Add the server. We only send more requests if the connection will
701 if (Srv
->Out
.WriteSpace() == true && Srv
->ServerFd
!= -1
702 && Srv
->Persistent
== true)
703 FD_SET(Srv
->ServerFd
,&wfds
);
704 if (Srv
->In
.ReadSpace() == true && Srv
->ServerFd
!= -1)
705 FD_SET(Srv
->ServerFd
,&rfds
);
712 if (Srv
->In
.WriteSpace() == true && ToFile
== true && FileFD
!= -1)
713 FD_SET(FileFD
,&wfds
);
716 FD_SET(STDIN_FILENO
,&rfds
);
718 // Figure out the max fd
720 if (MaxFd
< Srv
->ServerFd
)
721 MaxFd
= Srv
->ServerFd
;
728 if ((Res
= select(MaxFd
+1,&rfds
,&wfds
,0,&tv
)) < 0)
732 return _error
->Errno("select","Select failed");
737 _error
->Error("Connection timed out");
738 return ServerDie(Srv
);
742 if (Srv
->ServerFd
!= -1 && FD_ISSET(Srv
->ServerFd
,&rfds
))
745 if (Srv
->In
.Read(Srv
->ServerFd
) == false)
746 return ServerDie(Srv
);
749 if (Srv
->ServerFd
!= -1 && FD_ISSET(Srv
->ServerFd
,&wfds
))
752 if (Srv
->Out
.Write(Srv
->ServerFd
) == false)
753 return ServerDie(Srv
);
756 // Send data to the file
757 if (FileFD
!= -1 && FD_ISSET(FileFD
,&wfds
))
759 if (Srv
->In
.Write(FileFD
) == false)
760 return _error
->Errno("write","Error writing to output file");
763 // Handle commands from APT
764 if (FD_ISSET(STDIN_FILENO
,&rfds
))
773 // HttpMethod::Flush - Dump the buffer into the file /*{{{*/
774 // ---------------------------------------------------------------------
775 /* This takes the current input buffer from the Server FD and writes it
777 bool HttpMethod::Flush(ServerState
*Srv
)
781 SetNonBlock(File
->Fd(),false);
782 if (Srv
->In
.WriteSpace() == false)
785 while (Srv
->In
.WriteSpace() == true)
787 if (Srv
->In
.Write(File
->Fd()) == false)
788 return _error
->Errno("write","Error writing to file");
789 if (Srv
->In
.IsLimit() == true)
793 if (Srv
->In
.IsLimit() == true || Srv
->Encoding
== ServerState::Closes
)
799 // HttpMethod::ServerDie - The server has closed the connection. /*{{{*/
800 // ---------------------------------------------------------------------
802 bool HttpMethod::ServerDie(ServerState
*Srv
)
804 unsigned int LErrno
= errno
;
806 // Dump the buffer to the file
807 if (Srv
->State
== ServerState::Data
)
809 SetNonBlock(File
->Fd(),false);
810 while (Srv
->In
.WriteSpace() == true)
812 if (Srv
->In
.Write(File
->Fd()) == false)
813 return _error
->Errno("write","Error writing to the file");
816 if (Srv
->In
.IsLimit() == true)
821 // See if this is because the server finished the data stream
822 if (Srv
->In
.IsLimit() == false && Srv
->State
!= ServerState::Header
&&
823 Srv
->Encoding
!= ServerState::Closes
)
827 return _error
->Error("Error reading from server Remote end closed connection");
829 return _error
->Errno("read","Error reading from server");
835 // Nothing left in the buffer
836 if (Srv
->In
.WriteSpace() == false)
839 // We may have got multiple responses back in one packet..
847 // HttpMethod::DealWithHeaders - Handle the retrieved header data /*{{{*/
848 // ---------------------------------------------------------------------
849 /* We look at the header data we got back from the server and decide what
853 3 - Unrecoverable error
854 4 - Error with error content page
855 5 - Unrecoverable non-server error (close the connection) */
856 int HttpMethod::DealWithHeaders(FetchResult
&Res
,ServerState
*Srv
)
859 if (Srv
->Result
== 304)
861 unlink(Queue
->DestFile
.c_str());
863 Res
.LastModified
= Queue
->LastModified
;
867 /* We have a reply we dont handle. This should indicate a perm server
869 if (Srv
->Result
< 200 || Srv
->Result
>= 300)
871 _error
->Error("%u %s",Srv
->Result
,Srv
->Code
);
872 if (Srv
->HaveContent
== true)
877 // This is some sort of 2xx 'data follows' reply
878 Res
.LastModified
= Srv
->Date
;
879 Res
.Size
= Srv
->Size
;
883 File
= new FileFd(Queue
->DestFile
,FileFd::WriteAny
);
884 if (_error
->PendingError() == true)
887 FailFile
= Queue
->DestFile
;
888 FailFile
.c_str(); // Make sure we dont do a malloc in the signal handler
890 FailTime
= Srv
->Date
;
892 // Set the expected size
893 if (Srv
->StartPos
>= 0)
895 Res
.ResumePoint
= Srv
->StartPos
;
896 ftruncate(File
->Fd(),Srv
->StartPos
);
899 // Set the start point
900 lseek(File
->Fd(),0,SEEK_END
);
903 Srv
->In
.Hash
= new Hashes
;
905 // Fill the Hash if the file is non-empty (resume)
906 if (Srv
->StartPos
> 0)
908 lseek(File
->Fd(),0,SEEK_SET
);
909 if (Srv
->In
.Hash
->AddFD(File
->Fd(),Srv
->StartPos
) == false)
911 _error
->Errno("read","Problem hashing file");
914 lseek(File
->Fd(),0,SEEK_END
);
917 SetNonBlock(File
->Fd(),true);
921 // HttpMethod::SigTerm - Handle a fatal signal /*{{{*/
922 // ---------------------------------------------------------------------
923 /* This closes and timestamps the open file. This is neccessary to get
924 resume behavoir on user abort */
925 void HttpMethod::SigTerm(int)
933 UBuf
.actime
= FailTime
;
934 UBuf
.modtime
= FailTime
;
935 utime(FailFile
.c_str(),&UBuf
);
940 // HttpMethod::Fetch - Fetch an item /*{{{*/
941 // ---------------------------------------------------------------------
942 /* This adds an item to the pipeline. We keep the pipeline at a fixed
944 bool HttpMethod::Fetch(FetchItem
*)
949 // Queue the requests
952 for (FetchItem
*I
= Queue
; I
!= 0 && Depth
< (signed)PipelineDepth
;
953 I
= I
->Next
, Depth
++)
955 // If pipelining is disabled, we only queue 1 request
956 if (Server
->Pipeline
== false && Depth
>= 0)
959 // Make sure we stick with the same server
960 if (Server
->Comp(I
->Uri
) == false)
967 SendReq(I
,Server
->Out
);
975 // HttpMethod::Configuration - Handle a configuration message /*{{{*/
976 // ---------------------------------------------------------------------
977 /* We stash the desired pipeline depth */
978 bool HttpMethod::Configuration(string Message
)
980 if (pkgAcqMethod::Configuration(Message
) == false)
983 TimeOut
= _config
->FindI("Acquire::http::Timeout",TimeOut
);
984 PipelineDepth
= _config
->FindI("Acquire::http::Pipeline-Depth",
986 Debug
= _config
->FindB("Debug::Acquire::http",false);
991 // HttpMethod::Loop - Main loop /*{{{*/
992 // ---------------------------------------------------------------------
994 int HttpMethod::Loop()
996 signal(SIGTERM
,SigTerm
);
997 signal(SIGINT
,SigTerm
);
1001 int FailCounter
= 0;
1004 // We have no commands, wait for some to arrive
1007 if (WaitFd(STDIN_FILENO
) == false)
1011 /* Run messages, we can accept 0 (no message) if we didn't
1012 do a WaitFd above.. Otherwise the FD is closed. */
1013 int Result
= Run(true);
1014 if (Result
!= -1 && (Result
!= 0 || Queue
== 0))
1020 // Connect to the server
1021 if (Server
== 0 || Server
->Comp(Queue
->Uri
) == false)
1024 Server
= new ServerState(Queue
->Uri
,this);
1027 /* If the server has explicitly said this is the last connection
1028 then we pre-emptively shut down the pipeline and tear down
1029 the connection. This will speed up HTTP/1.0 servers a tad
1030 since we don't have to wait for the close sequence to
1032 if (Server
->Persistent
== false)
1035 // Reset the pipeline
1036 if (Server
->ServerFd
== -1)
1039 // Connnect to the host
1040 if (Server
->Open() == false)
1048 // Fill the pipeline.
1051 // Fetch the next URL header data from the server.
1052 switch (Server
->RunHeaders())
1057 // The header data is bad
1060 _error
->Error("Bad header Data");
1066 // The server closed a connection during the header get..
1073 Server
->Pipeline
= false;
1075 if (FailCounter
>= 2)
1077 Fail("Connection failed",true);
1086 // Decide what to do.
1088 Res
.Filename
= Queue
->DestFile
;
1089 switch (DealWithHeaders(Res
,Server
))
1091 // Ok, the file is Open
1097 bool Result
= Server
->RunData();
1099 /* If the server is sending back sizeless responses then fill in
1102 Res
.Size
= File
->Size();
1104 // Close the file, destroy the FD object and timestamp it
1110 struct utimbuf UBuf
;
1112 UBuf
.actime
= Server
->Date
;
1113 UBuf
.modtime
= Server
->Date
;
1114 utime(Queue
->DestFile
.c_str(),&UBuf
);
1116 // Send status to APT
1119 Res
.TakeHashes(*Server
->In
.Hash
);
1135 // Hard server error, not found or something
1142 // Hard internal error, kill the connection and fail
1154 // We need to flush the data, the header is like a 404 w/ error text
1159 // Send to content to dev/null
1160 File
= new FileFd("/dev/null",FileFd::WriteExists
);
1168 Fail("Internal error");