| OLD | NEW |
| (Empty) |
| 1 // Copyright 2007-2010 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 // | |
| 16 // HttpRequestInterface defines an interface for http transactions, with an | |
| 17 // optional number of retries, going over a specified network configuration. | |
| 18 // | |
| 19 // TODO(omaha): the class interface is not stable yet, as a few more | |
| 20 // getters and setters are still needed. | |
| 21 // | |
| 22 // TODO(omaha): provide a way to query how many bytes have been downloaded | |
| 23 // when the Send() returns so that the code doesn't have to rely on a final | |
| 24 // callback to update the progress information. | |
| 25 | |
| 26 #ifndef OMAHA_NET_HTTP_REQUEST_H__ | |
| 27 #define OMAHA_NET_HTTP_REQUEST_H__ | |
| 28 | |
| 29 #include <atlstr.h> | |
| 30 #include <vector> | |
| 31 #include "base/basictypes.h" | |
| 32 #include "omaha/net/network_config.h" | |
| 33 | |
| 34 namespace omaha { | |
| 35 | |
| 36 class NetworkRequestCallback; | |
| 37 | |
| 38 class HttpRequestInterface { | |
| 39 public: | |
| 40 virtual ~HttpRequestInterface() {} | |
| 41 | |
| 42 virtual HRESULT Close() = 0; | |
| 43 | |
| 44 // Sends a fault-tolerant http request. Returns S_OK if the http transaction | |
| 45 // went through and the correct response is available. | |
| 46 virtual HRESULT Send() = 0; | |
| 47 | |
| 48 virtual HRESULT Cancel() = 0; | |
| 49 | |
| 50 virtual HRESULT Pause() = 0; | |
| 51 | |
| 52 virtual HRESULT Resume() = 0; | |
| 53 | |
| 54 virtual std::vector<uint8> GetResponse() const = 0; | |
| 55 | |
| 56 virtual int GetHttpStatusCode() const = 0; | |
| 57 | |
| 58 virtual HRESULT QueryHeadersString(uint32 info_level, | |
| 59 const TCHAR* name, | |
| 60 CString* value) const = 0; | |
| 61 | |
| 62 virtual CString GetResponseHeaders() const = 0; | |
| 63 | |
| 64 virtual CString ToString() const = 0; | |
| 65 | |
| 66 virtual void set_session_handle(HINTERNET session_handle) = 0; | |
| 67 | |
| 68 virtual void set_url(const CString& url) = 0; | |
| 69 | |
| 70 virtual void set_request_buffer(const void* buffer, | |
| 71 size_t buffer_length) = 0; | |
| 72 | |
| 73 virtual void set_proxy_configuration(const ProxyConfig& proxy_config) = 0; | |
| 74 | |
| 75 // Sets the filename to receive the response instead of the memory buffer. | |
| 76 virtual void set_filename(const CString& filename) = 0; | |
| 77 | |
| 78 virtual void set_low_priority(bool low_priority) = 0; | |
| 79 | |
| 80 virtual void set_callback(NetworkRequestCallback* callback) = 0; | |
| 81 | |
| 82 virtual void set_additional_headers(const CString& additional_headers) = 0; | |
| 83 | |
| 84 virtual void set_preserve_protocol(bool preserve_protocol) = 0; | |
| 85 | |
| 86 // Gets the user agent for this http request. The default user agent has | |
| 87 // the following format: Google Update/a.b.c.d;req1;req2 where a.b.c.d is | |
| 88 // the version of the client code and req1, req2,... are appended by | |
| 89 // different http requests. For example: | |
| 90 // User-Agent: Google Update/1.2.15.0;winhttp;cup | |
| 91 // indicates a WinHTTP+CUP request. | |
| 92 virtual CString user_agent() const = 0; | |
| 93 | |
| 94 virtual void set_user_agent(const CString& user_agent) = 0; | |
| 95 | |
| 96 virtual void set_proxy_auth_config(const ProxyAuthConfig& config) = 0; | |
| 97 }; | |
| 98 | |
| 99 } // namespace omaha | |
| 100 | |
| 101 #endif // OMAHA_NET_HTTP_REQUEST_H__ | |
| 102 | |
| OLD | NEW |