]>
git.saurik.com Git - apt.git/blob - methods/http.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/// $Id: http.h,v 1.8 2000/05/28 04:33:59 jgg Exp $
3 /* ######################################################################
5 HTTP Aquire Method - This is the HTTP aquire method for APT.
7 ##################################################################### */
28 unsigned long LeftRead()
30 unsigned long Sz
= Size
- (InP
- OutP
);
31 if (Sz
> Size
- (InP%Size
))
32 Sz
= Size
- (InP%Size
);
35 unsigned long LeftWrite()
37 unsigned long Sz
= InP
- OutP
;
40 if (Sz
> Size
- (OutP%Size
))
41 Sz
= Size
- (OutP%Size
);
52 bool Read(string Data
);
56 bool WriteTillEl(string
&Data
,bool Single
= false);
58 // Control the write limit
59 void Limit(long Max
) {if (Max
== -1) MaxGet
= 0-1; else MaxGet
= OutP
+ Max
;}
60 bool IsLimit() {return MaxGet
== OutP
;};
61 void Print() {cout
<< MaxGet
<< ',' << OutP
<< endl
;};
63 // Test for free space in the buffer
64 bool ReadSpace() {return Size
- (InP
- OutP
) > 0;};
65 bool WriteSpace() {return InP
- OutP
> 0;};
71 CircleBuf(unsigned long Size
);
72 ~CircleBuf() {delete [] Buf
;};
77 // This is the last parsed Header Line
83 // These are some statistics from the last parsed header lines
88 enum {Chunked
,Stream
,Closes
} Encoding
;
89 enum {Header
, Data
} State
;
92 // This is a Persistent attribute of the server itself.
97 // This is the connection itself. Output is data FROM the server
103 bool HeaderLine(string Line
);
104 bool Comp(URI Other
) {return Other
.Host
== ServerName
.Host
&& Other
.Port
== ServerName
.Port
;};
105 void Reset() {Major
= 0; Minor
= 0; Result
= 0; Size
= 0; StartPos
= 0;
106 Encoding
= Closes
; time(&Date
); ServerFd
= -1;
114 ServerState(URI Srv
,HttpMethod
*Owner
);
115 ~ServerState() {Close();};
118 class HttpMethod
: public pkgAcqMethod
120 void SendReq(FetchItem
*Itm
,CircleBuf
&Out
);
121 bool Go(bool ToFile
,ServerState
*Srv
);
122 bool Flush(ServerState
*Srv
);
123 bool ServerDie(ServerState
*Srv
);
124 int DealWithHeaders(FetchResult
&Res
,ServerState
*Srv
);
126 virtual bool Fetch(FetchItem
*);
127 virtual bool Configuration(string Message
);
129 // In the event of a fatal signal this file will be closed and timestamped.
130 static string FailFile
;
132 static time_t FailTime
;
133 static void SigTerm(int);
143 HttpMethod() : pkgAcqMethod("1.2",Pipeline
| SendConfig
)