diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-03-15 15:07:18 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-03-15 15:07:18 +0000 |
| commit | 11907c175d9e3e6f4069df79dade320b6f93cd7f (patch) | |
| tree | d866782e0cc2a2eafd48ae3ac2612c280cdd6daa /src/HttpConnection.h | |
| parent | ba7f9f765794bc197750253f07211c66afdd69e5 (diff) | |
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
Diffstat (limited to 'src/HttpConnection.h')
| -rw-r--r-- | src/HttpConnection.h | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/HttpConnection.h b/src/HttpConnection.h index 1c60f95c..d94ddc27 100644 --- a/src/HttpConnection.h +++ b/src/HttpConnection.h @@ -40,33 +40,29 @@ #include "Request.h" #include "Option.h" #include "Logger.h" -#include "HttpHeader.h" #include "common.h" #include "Logger.h" +#include "HttpResponse.h" +#include <netinet/in.h> #include <string> -using namespace std; - #define HEADERBUF_SIZE 4096 class HttpConnection { private: - string getHost(const string& host, int port) const; - string createRequest(const Segment& segment) const; - int findEndOfHeader(const char* buf, const char* substr, int bufLength) const; - bool useProxy() const; - bool useProxyAuth() const; - bool useProxyGet() const; - string getProxyAuthString() const; int cuid; SocketHandle socket; - RequestHandle req; const Option* option; const Logger* logger; char headerBuf[HEADERBUF_SIZE+1]; int headerBufLength; + + HttpRequests outstandingHttpRequests; + + int findEndOfHeader(const char* buf, const char* substr, int bufLength) const; public: - HttpConnection(int cuid, const SocketHandle& socket, const RequestHandle req, + HttpConnection(int cuid, + const SocketHandle& socket, const Option* op); /** @@ -76,25 +72,34 @@ public: * HTTP proxy(GET method). * @param segment indicates starting postion of the file for downloading */ - void sendRequest(const Segment& segment) const; + void sendRequest(const HttpRequestHandle& httpRequest); /** * Sends Http proxy request using CONNECT method. */ - void sendProxyRequest() const; + void sendProxyRequest(const HttpRequestHandle& httpRequest); /** - * Receives HTTP response from the server and store the response header - * into the variable headers. - * If response header is not fully received, received header is buffured - * in this object and headers is undefined and this method returns 0. + * Receives HTTP response from the server and returns HttpResponseHandle + * object which contains response header and HttpRequestHandle object + * for this response. + * If a response is not fully received, received header is buffured + * in this object and returns 0. * You should continue to call this method until whole response header is - * received and this method returns non-zero value. + * received and this method returns non-null HttpResponseHandle object. * - * @param headers holder to store HTTP response header - * @return HTTP status or 0 if whole response header is not received + * @return HttpResponse or 0 if whole response header is not received */ - int receiveResponse(HttpHeader& headers); + HttpResponseHandle receiveResponse(); + + HttpRequestHandle getFirstHttpRequest() const + { + if(outstandingHttpRequests.size() > 0) { + return outstandingHttpRequests.front(); + } else { + return 0; + } + } }; typedef SharedHandle<HttpConnection> HttpConnectionHandle; |
