OLD | NEW |
| (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 // CupRequest provides CUP capabilities for a generic HttpRequestInterface. | |
17 | |
18 #ifndef OMAHA_NET_CUP_REQUEST_H__ | |
19 #define OMAHA_NET_CUP_REQUEST_H__ | |
20 | |
21 #include <windows.h> | |
22 #include <atlstr.h> | |
23 #include <vector> | |
24 #include "base/basictypes.h" | |
25 #include "omaha/net/http_request.h" | |
26 #include "base/scoped_ptr.h" | |
27 | |
28 namespace omaha { | |
29 | |
30 namespace detail { | |
31 | |
32 // The implementation uses the pimpl idiom or bridge design pattern to | |
33 // encapsulate the cup protocol implementation details from the calling code. | |
34 class CupRequestImpl; | |
35 | |
36 } // namespace detail | |
37 | |
38 class CupRequest : public HttpRequestInterface { | |
39 public: | |
40 // Decorates an HttpRequestInterface to provide CUP functionality. | |
41 // It takes ownership of the object provided as parameter. | |
42 explicit CupRequest(HttpRequestInterface* http_request); | |
43 | |
44 virtual ~CupRequest(); | |
45 | |
46 virtual HRESULT Close(); | |
47 | |
48 virtual HRESULT Send(); | |
49 | |
50 virtual HRESULT Cancel(); | |
51 | |
52 virtual HRESULT Pause(); | |
53 | |
54 virtual HRESULT Resume(); | |
55 | |
56 virtual std::vector<uint8> GetResponse() const; | |
57 | |
58 virtual HRESULT QueryHeadersString(uint32 info_level, | |
59 const TCHAR* name, | |
60 CString* value) const; | |
61 virtual CString GetResponseHeaders() const; | |
62 | |
63 virtual int GetHttpStatusCode() const; | |
64 | |
65 virtual CString ToString() const; | |
66 | |
67 virtual void set_session_handle(HINTERNET session_handle); | |
68 | |
69 virtual void set_url(const CString& url); | |
70 | |
71 virtual void set_request_buffer(const void* buffer, size_t buffer_length); | |
72 | |
73 virtual void set_proxy_configuration(const ProxyConfig& proxy_config); | |
74 | |
75 // Sets the filename to receive the response instead of the memory buffer. | |
76 virtual void set_filename(const CString& filename); | |
77 | |
78 virtual void set_low_priority(bool low_priority); | |
79 | |
80 virtual void set_callback(NetworkRequestCallback* callback); | |
81 | |
82 virtual void set_additional_headers(const CString& additional_headers); | |
83 | |
84 virtual void set_preserve_protocol(bool preserve_protocol); | |
85 | |
86 virtual CString user_agent() const; | |
87 | |
88 virtual void set_user_agent(const CString& user_agent); | |
89 | |
90 virtual void set_proxy_auth_config(const ProxyAuthConfig& proxy_auth_config); | |
91 | |
92 // Sets random bytes provided by the caller. This is useful for testing | |
93 // purposes and it is not be called by production code. | |
94 // Otherwise, when entropy is not provided, the implementation | |
95 // fills in the internal entropy buffer with cryptographically random bytes. | |
96 // Calling this method can result in compromising the security of the | |
97 // protocol, depending on the quality of entropy provided. | |
98 void SetEntropy(const void* data, size_t data_length); | |
99 | |
100 private: | |
101 | |
102 scoped_ptr<detail::CupRequestImpl> impl_; | |
103 DISALLOW_EVIL_CONSTRUCTORS(CupRequest); | |
104 }; | |
105 | |
106 } // namespace omaha | |
107 | |
108 #endif // OMAHA_NET_CUP_REQUEST_H__ | |
109 | |
OLD | NEW |