X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2FHTTPRequest.hxx;h=0def08880162c667d9f714f490dc99dbdd0ecbd4;hb=8d93206dd33ed0079af6670a0ecd41a3b203d9a0;hp=2365b85526895dc096d6e9343e55bab851b1d9a8;hpb=f41b18f0649a50e179ba41383f4061e1878c4d4c;p=simgear.git diff --git a/simgear/io/HTTPRequest.hxx b/simgear/io/HTTPRequest.hxx index 2365b855..0def0888 100644 --- a/simgear/io/HTTPRequest.hxx +++ b/simgear/io/HTTPRequest.hxx @@ -37,6 +37,8 @@ namespace simgear namespace HTTP { +class Client; + /** * Base class for HTTP request (and answer). */ @@ -50,6 +52,7 @@ public: { UNSENT = 0, OPENED, + STATUS_RECEIVED, HEADERS_RECEIVED, LOADING, DONE, @@ -124,19 +127,22 @@ public: void setBodyData( const SGPropertyNode* data ); virtual void setUrl(const std::string& url); - + virtual std::string method() const { return _method; } virtual std::string url() const { return _url; } - + + Client* http() const + { return _client; } + virtual std::string scheme() const; virtual std::string path() const; virtual std::string host() const; virtual std::string hostAndPort() const; virtual unsigned short port() const; virtual std::string query() const; - + StringMap const& responseHeaders() const { return _responseHeaders; } @@ -144,13 +150,13 @@ public: virtual int responseCode() const { return _responseStatus; } - + virtual std::string responseReason() const { return _responseReason; } - + void setResponseLength(unsigned int l); virtual unsigned int responseLength() const; - + /** * Check if request contains body data. */ @@ -165,46 +171,43 @@ public: * Retrieve the size of the request body. */ virtual size_t bodyLength() const; - + /** * Retrieve the body data bytes. Will be passed the maximum body bytes * to return in the buffer, and must return the actual number - * of bytes written. + * of bytes written. */ virtual size_t getBodyData(char* s, size_t offset, size_t max_count) const; - + /** * running total of body bytes received so far. Can be used * to generate a completion percentage, if the response length is - * known. + * known. */ unsigned int responseBytesReceived() const { return _receivedBodyBytes; } - + enum HTTPVersion { HTTP_VERSION_UNKNOWN = 0, HTTP_0_x, // 0.9 or similar HTTP_1_0, HTTP_1_1 }; - + HTTPVersion responseVersion() const { return _responseVersion; } - + ReadyState readyState() const { return _ready_state; } - /** - * Request aborting this request. - */ - void abort(); + bool closeAfterComplete() const; + bool isComplete() const; /** - * Request aborting this request and specify the reported reaseon for it. + * Check if the server response indicates pipelining should be continued. + * Currently tests that HTTP_1_1 is explicitly supported, and that the + * server/proxy did not request Connection: close */ - void abort(const std::string& reason); - - bool closeAfterComplete() const; - bool isComplete() const; + bool serverSupportsPipelining() const; protected: Request(const std::string& url, const std::string method = "GET"); @@ -226,13 +229,17 @@ private: friend class Client; friend class Connection; friend class ContentDecoder; - + Request(const Request&); // = delete; Request& operator=(const Request&); // = delete; void processBodyBytes(const char* s, int n); void setReadyState(ReadyState state); + void setCloseAfterComplete(); + + Client* _client; // HTTP client we're active on + std::string _method; std::string _url; StringMap _request_headers; @@ -252,6 +259,7 @@ private: ReadyState _ready_state; bool _willClose; + bool _connectionCloseHeader; }; typedef SGSharedPtr Request_ptr;