From 72d60c2c3ab73b9c9d6142129fa078cfc09eefbd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 3 Jan 2009 08:59:47 +0000 Subject: Add ability to send an HTTPRequest to a socket and to parse an HTTPResponse from a socket, to create a simple HTTP client. --- lib/httpserver/HTTPResponse.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/httpserver/HTTPResponse.h') diff --git a/lib/httpserver/HTTPResponse.h b/lib/httpserver/HTTPResponse.h index c6b57e40..58cc3baa 100644 --- a/lib/httpserver/HTTPResponse.h +++ b/lib/httpserver/HTTPResponse.h @@ -15,6 +15,8 @@ #include "CollectInBufferStream.h" +class IOStreamGetLine; + // -------------------------------------------------------------------------- // // Class @@ -35,15 +37,18 @@ private: public: void SetResponseCode(int Code); + int GetResponseCode() { return mResponseCode; } void SetContentType(const char *ContentType); + const std::string& GetContentType() { return mContentType; } void SetAsRedirect(const char *RedirectTo, bool IsLocalURI = true); void SetAsNotFound(const char *URI); void Send(IOStream &rStream, bool OmitContent = false); + void Receive(IOStream& rStream, int Timeout = IOStream::TimeOutInfinite); - void AddHeader(const char *EntireHeaderLine); - void AddHeader(const std::string &rEntireHeaderLine); + // void AddHeader(const char *EntireHeaderLine); + // void AddHeader(const std::string &rEntireHeaderLine); void AddHeader(const char *Header, const char *Value); void AddHeader(const char *Header, const std::string &rValue); void AddHeader(const std::string &rHeader, const std::string &rValue); @@ -106,9 +111,13 @@ private: bool mResponseIsDynamicContent; bool mKeepAlive; std::string mContentType; - std::vector mExtraHeaders; + typedef std::pair Header; + std::vector
mExtraHeaders; + int mContentLength; // only used when reading response from stream static std::string msDefaultURIPrefix; + + void ParseHeaders(IOStreamGetLine &rGetLine, int Timeout); }; #endif // HTTPRESPONSE__H -- cgit v1.2.3