Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: net/urlmon_request.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/simple_request_unittest.cc ('k') | net/urlmon_request.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2008-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 // UrlmonRequest sends http transactions through urlmon.dll
17
18 #ifndef OMAHA_NET_URLMON_REQUEST_H__
19 #define OMAHA_NET_URLMON_REQUEST_H__
20
21 #include <windows.h>
22 #include <atlstr.h>
23 #include <atlsafe.h>
24 #include <map>
25 #include <vector>
26 #include "base/basictypes.h"
27 #include "omaha/base/debug.h"
28 #include "omaha/net/bind_status_callback.h"
29 #include "omaha/net/http_request.h"
30
31 namespace omaha {
32
33 class UrlmonRequest : public HttpRequestInterface {
34 public:
35 UrlmonRequest();
36 virtual ~UrlmonRequest();
37
38 // HttpRequestInterface methods.
39 virtual HRESULT Close();
40
41 virtual HRESULT Send();
42
43 virtual HRESULT Cancel();
44
45 virtual HRESULT Pause();
46
47 virtual HRESULT Resume();
48
49 virtual std::vector<uint8> GetResponse() const {
50 return response_body_;
51 }
52
53 virtual int GetHttpStatusCode() const {
54 return http_status_code_;
55 }
56
57 virtual HRESULT QueryHeadersString(uint32 info_level,
58 const TCHAR* name,
59 CString* value) const {
60 // TODO(Omaha) - support for a custom name string.
61 name;
62
63 ASSERT1(value);
64 value->Empty();
65 std::map<DWORD, CString>::const_iterator cur =
66 response_headers_map_.find(info_level);
67 if (cur != response_headers_map_.end()) {
68 *value = cur->second;
69 }
70 return !value->IsEmpty() ? S_OK : E_FAIL;
71 }
72
73 virtual CString GetResponseHeaders() const {
74 return raw_response_headers_;
75 }
76
77 virtual CString ToString() const { return _T("urlmon"); }
78
79 // No effect for this class.
80 virtual void set_session_handle(HINTERNET) {}
81
82 virtual void set_url(const CString& url) { url_ = url; }
83
84 virtual void set_request_buffer(const void* buffer, size_t buffer_length) {
85 request_buffer_ = buffer;
86 request_buffer_length_ = buffer_length;
87 }
88
89 virtual void set_proxy_configuration(const ProxyConfig& proxy_config) {
90 proxy_config_ = proxy_config;
91 }
92
93 virtual void set_network_configuration(const ProxyConfig& network_config) {
94 UNREFERENCED_PARAMETER(network_config);
95 }
96
97 // Sets the filename to receive the response instead of the memory buffer.
98 virtual void set_filename(const CString& filename) { filename_ = filename; }
99
100 virtual void set_low_priority(bool low_priority) {
101 UNREFERENCED_PARAMETER(low_priority);
102 }
103
104 virtual void set_callback(NetworkRequestCallback* callback) {
105 // TODO(Omaha) - Provide events.
106 UNREFERENCED_PARAMETER(callback);
107 }
108
109 virtual void set_additional_headers(const CString& additional_headers) {
110 additional_headers_ = additional_headers;
111 }
112
113 // This request always uses the specified protocol so it is fine to ignore
114 // this attribute.
115 virtual void set_preserve_protocol(bool preserve_protocol) {
116 UNREFERENCED_PARAMETER(preserve_protocol);
117 }
118
119 virtual CString user_agent() const { return user_agent_; }
120
121 virtual void set_user_agent(const CString& user_agent) {
122 user_agent_ = user_agent;
123 }
124
125 virtual void set_proxy_auth_config(const ProxyAuthConfig& proxy_auth_config) {
126 proxy_auth_config_ = proxy_auth_config;
127 }
128
129 virtual HRESULT SendRequest(BSTR url,
130 BSTR post_data,
131 BSTR request_headers,
132 VARIANT response_headers_needed,
133 CComVariant* response_headers,
134 DWORD* response_code,
135 BSTR* cache_filename);
136
137 protected:
138 CString user_agent_;
139 ProxyAuthConfig proxy_auth_config_;
140 ProxyConfig proxy_config_;
141
142 private:
143 HRESULT ProcessResponseHeaders(const CComVariant& headers,
144 const CComSafeArray<DWORD>& headers_needed);
145 HRESULT ProcessResponseFile(const CComBSTR& cache_filename);
146 bool CreateBrowserHttpRequest();
147
148 CComObjectStackEx<BindStatusCallback> bsc_;
149 CComBSTR url_;
150 CString filename_;
151 const void* request_buffer_; // Contains the request body for POST.
152 size_t request_buffer_length_; // Length of the request body.
153 CString additional_headers_;
154
155 volatile LONG is_cancelled_;
156 DWORD http_status_code_;
157 std::vector<uint8> response_body_;
158 std::map<DWORD, CString> response_headers_map_;
159 CString raw_response_headers_;
160
161 DISALLOW_EVIL_CONSTRUCTORS(UrlmonRequest);
162 };
163
164 } // namespace omaha
165
166 #endif // OMAHA_NET_URLMON_REQUEST_H__
167
OLDNEW
« no previous file with comments | « net/simple_request_unittest.cc ('k') | net/urlmon_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698