| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef _HTTPREQUEST_H_ | |
| 12 #define _HTTPREQUEST_H_ | |
| 13 | |
| 14 #include "webrtc/base/httpclient.h" | |
| 15 #include "webrtc/base/logging.h" | |
| 16 #include "webrtc/base/proxyinfo.h" | |
| 17 #include "webrtc/base/socketserver.h" | |
| 18 #include "webrtc/base/thread.h" | |
| 19 #include "webrtc/base/sslsocketfactory.h" // Deprecated include | |
| 20 | |
| 21 namespace rtc { | |
| 22 | |
| 23 /////////////////////////////////////////////////////////////////////////////// | |
| 24 // HttpRequest | |
| 25 /////////////////////////////////////////////////////////////////////////////// | |
| 26 | |
| 27 class FirewallManager; | |
| 28 class MemoryStream; | |
| 29 | |
| 30 class HttpRequest { | |
| 31 public: | |
| 32 HttpRequest(const std::string &user_agent); | |
| 33 ~HttpRequest(); | |
| 34 | |
| 35 void Send(); | |
| 36 | |
| 37 void set_proxy(const ProxyInfo& proxy) { | |
| 38 proxy_ = proxy; | |
| 39 } | |
| 40 void set_firewall(FirewallManager * firewall) { | |
| 41 firewall_ = firewall; | |
| 42 } | |
| 43 | |
| 44 // The DNS name of the host to connect to. | |
| 45 const std::string& host() { return host_; } | |
| 46 void set_host(const std::string& host) { host_ = host; } | |
| 47 | |
| 48 // The port to connect to on the target host. | |
| 49 int port() { return port_; } | |
| 50 void set_port(int port) { port_ = port; } | |
| 51 | |
| 52 // Whether the request should use SSL. | |
| 53 bool secure() { return secure_; } | |
| 54 void set_secure(bool secure) { secure_ = secure; } | |
| 55 | |
| 56 // Returns the redirect when redirection occurs | |
| 57 const std::string& response_redirect() { return response_redirect_; } | |
| 58 | |
| 59 // Time to wait on the download, in ms. Default is 5000 (5s) | |
| 60 int timeout() { return timeout_; } | |
| 61 void set_timeout(int timeout) { timeout_ = timeout; } | |
| 62 | |
| 63 // Fail redirects to allow analysis of redirect urls, etc. | |
| 64 bool fail_redirect() const { return fail_redirect_; } | |
| 65 void set_fail_redirect(bool fail_redirect) { fail_redirect_ = fail_redirect; } | |
| 66 | |
| 67 HttpRequestData& request() { return client_.request(); } | |
| 68 HttpResponseData& response() { return client_.response(); } | |
| 69 HttpErrorType error() { return error_; } | |
| 70 | |
| 71 protected: | |
| 72 void set_error(HttpErrorType error) { error_ = error; } | |
| 73 | |
| 74 private: | |
| 75 ProxyInfo proxy_; | |
| 76 FirewallManager * firewall_; | |
| 77 std::string host_; | |
| 78 int port_; | |
| 79 bool secure_; | |
| 80 int timeout_; | |
| 81 bool fail_redirect_; | |
| 82 HttpClient client_; | |
| 83 HttpErrorType error_; | |
| 84 std::string response_redirect_; | |
| 85 }; | |
| 86 | |
| 87 /////////////////////////////////////////////////////////////////////////////// | |
| 88 // HttpMonitor | |
| 89 /////////////////////////////////////////////////////////////////////////////// | |
| 90 | |
| 91 class HttpMonitor : public sigslot::has_slots<> { | |
| 92 public: | |
| 93 HttpMonitor(SocketServer *ss); | |
| 94 | |
| 95 void reset() { | |
| 96 complete_ = false; | |
| 97 error_ = HE_DEFAULT; | |
| 98 } | |
| 99 | |
| 100 bool done() const { return complete_; } | |
| 101 HttpErrorType error() const { return error_; } | |
| 102 | |
| 103 void Connect(HttpClient* http); | |
| 104 void OnHttpClientComplete(HttpClient * http, HttpErrorType error); | |
| 105 | |
| 106 private: | |
| 107 bool complete_; | |
| 108 HttpErrorType error_; | |
| 109 SocketServer *ss_; | |
| 110 }; | |
| 111 | |
| 112 /////////////////////////////////////////////////////////////////////////////// | |
| 113 | |
| 114 } // namespace rtc_ | |
| 115 | |
| 116 #endif // _HTTPREQUEST_H_ | |
| OLD | NEW |