3 * Copyright 2006, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef _HTTPREQUEST_H_
29 #define _HTTPREQUEST_H_
31 #include "talk/base/httpclient.h"
32 #include "talk/base/logging.h"
33 #include "talk/base/proxyinfo.h"
34 #include "talk/base/socketserver.h"
35 #include "talk/base/thread.h"
36 #include "talk/base/sslsocketfactory.h" // Deprecated include
40 ///////////////////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////////////////
44 class FirewallManager;
49 HttpRequest(const std::string &user_agent);
53 void set_proxy(const ProxyInfo& proxy) {
56 void set_firewall(FirewallManager * firewall) {
60 // The DNS name of the host to connect to.
61 const std::string& host() { return host_; }
62 void set_host(const std::string& host) { host_ = host; }
64 // The port to connect to on the target host.
65 int port() { return port_; }
66 void set_port(int port) { port_ = port; }
68 // Whether the request should use SSL.
69 bool secure() { return secure_; }
70 void set_secure(bool secure) { secure_ = secure; }
72 // Returns the redirect when redirection occurs
73 const std::string& response_redirect() { return response_redirect_; }
75 // Time to wait on the download, in ms. Default is 5000 (5s)
76 int timeout() { return timeout_; }
77 void set_timeout(int timeout) { timeout_ = timeout; }
79 // Fail redirects to allow analysis of redirect urls, etc.
80 bool fail_redirect() const { return fail_redirect_; }
81 void set_fail_redirect(bool fail_redirect) { fail_redirect_ = fail_redirect; }
83 HttpRequestData& request() { return client_.request(); }
84 HttpResponseData& response() { return client_.response(); }
85 HttpErrorType error() { return error_; }
88 void set_error(HttpErrorType error) { error_ = error; }
92 FirewallManager * firewall_;
100 std::string response_redirect_;
103 ///////////////////////////////////////////////////////////////////////////////
105 ///////////////////////////////////////////////////////////////////////////////
107 class HttpMonitor : public sigslot::has_slots<> {
109 HttpMonitor(SocketServer *ss);
116 bool done() const { return complete_; }
117 HttpErrorType error() const { return error_; }
119 void Connect(HttpClient* http);
120 void OnHttpClientComplete(HttpClient * http, HttpErrorType error);
124 HttpErrorType error_;
128 ///////////////////////////////////////////////////////////////////////////////
130 } // namespace talk_base_
132 #endif // _HTTPREQUEST_H_