X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2FHTTPRequest.hxx;h=0e346419d12632abd535f99782e370120d149467;hb=427d6c3316e59aa86bbf4d3e51f522e0aba9c4fd;hp=7cf498cd58e9d501c571c77e5809281f5ca070ea;hpb=19119cc4ae078dfb648f624cb5cff18ad86186a5;p=simgear.git diff --git a/simgear/io/HTTPRequest.hxx b/simgear/io/HTTPRequest.hxx index 7cf498cd..0e346419 100644 --- a/simgear/io/HTTPRequest.hxx +++ b/simgear/io/HTTPRequest.hxx @@ -37,27 +37,57 @@ public: virtual int responseCode() const { return _responseStatus; } - virtual std::string resposeReason() const + virtual std::string responseReason() const { return _responseReason; } - virtual unsigned int contentLength() const; -protected: - friend class Connection; + void setResponseLength(unsigned int l); + virtual unsigned int responseLength() const; + + /** + * running total of body bytes received so far. Can be used + * to generate a completion percentage, if the response length is + * 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; } - Request(const std::string& url, const std::string method = "get"); + static HTTPVersion decodeVersion(const std::string& v); + + bool closeAfterComplete() const; +protected: + Request(const std::string& url, const std::string method = "GET"); virtual void responseStart(const std::string& r); virtual void responseHeader(const std::string& key, const std::string& value); virtual void responseHeadersComplete(); virtual void responseComplete(); - + virtual void failed(); virtual void gotBodyData(const char* s, int n); private: + friend class Client; + friend class Connection; + + void processBodyBytes(const char* s, int n); + void setFailure(int code, const std::string& reason); std::string _method; std::string _url; + HTTPVersion _responseVersion; int _responseStatus; std::string _responseReason; + unsigned int _responseLength; + unsigned int _receivedBodyBytes; + bool _willClose; typedef std::map HeaderDict; HeaderDict _responseHeaders;