3 * Copyright 2004--2005, 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.
30 #include "talk/base/httpcommon-inl.h"
32 #include "talk/base/asyncsocket.h"
33 #include "talk/base/common.h"
34 #include "talk/base/diskcache.h"
35 #include "talk/base/httpclient.h"
36 #include "talk/base/logging.h"
37 #include "talk/base/pathutils.h"
38 #include "talk/base/socketstream.h"
39 #include "talk/base/stringencode.h"
40 #include "talk/base/stringutils.h"
41 #include "talk/base/thread.h"
45 //////////////////////////////////////////////////////////////////////
47 //////////////////////////////////////////////////////////////////////
51 const size_t kCacheHeader = 0;
52 const size_t kCacheBody = 1;
54 // Convert decimal string to integer
55 bool HttpStringToUInt(const std::string& str, size_t* val) {
58 *val = strtoul(str.c_str(), &eos, 10);
59 return (*eos == '\0');
62 bool HttpShouldCache(const HttpTransaction& t) {
63 bool verb_allows_cache = (t.request.verb == HV_GET)
64 || (t.request.verb == HV_HEAD);
65 bool is_range_response = t.response.hasHeader(HH_CONTENT_RANGE, NULL);
66 bool has_expires = t.response.hasHeader(HH_EXPIRES, NULL);
67 bool request_allows_cache =
68 has_expires || (std::string::npos != t.request.path.find('?'));
69 bool response_allows_cache =
70 has_expires || HttpCodeIsCacheable(t.response.scode);
72 bool may_cache = verb_allows_cache
73 && request_allows_cache
74 && response_allows_cache
75 && !is_range_response;
78 if (t.response.hasHeader(HH_CACHE_CONTROL, &value)) {
79 HttpAttributeList directives;
80 HttpParseAttributes(value.data(), value.size(), directives);
81 // Response Directives Summary:
82 // public - always cacheable
83 // private - do not cache in a shared cache
84 // no-cache - may cache, but must revalidate whether fresh or stale
85 // no-store - sensitive information, do not cache or store in any way
86 // max-age - supplants Expires for staleness
87 // s-maxage - use as max-age for shared caches, ignore otherwise
88 // must-revalidate - may cache, but must revalidate after stale
89 // proxy-revalidate - shared cache must revalidate
90 if (HttpHasAttribute(directives, "no-store", NULL)) {
92 } else if (HttpHasAttribute(directives, "public", NULL)) {
100 HCS_FRESH, // In cache, may use
101 HCS_STALE, // In cache, must revalidate
102 HCS_NONE // Not in cache
105 HttpCacheState HttpGetCacheState(const HttpTransaction& t) {
111 size_t now = time(0);
113 HttpAttributeList cache_control;
114 if (t.response.hasHeader(HH_CACHE_CONTROL, &s_temp)) {
115 HttpParseAttributes(s_temp.data(), s_temp.size(), cache_control);
118 // Compute age of cache document
120 if (!t.response.hasHeader(HH_DATE, &s_temp)
121 || !HttpDateToSeconds(s_temp, &date))
124 // TODO: Timestamp when cache request sent and response received?
125 time_t request_time = date;
126 time_t response_time = date;
128 time_t apparent_age = 0;
129 if (response_time > date) {
130 apparent_age = response_time - date;
133 size_t corrected_received_age = apparent_age;
135 if (t.response.hasHeader(HH_AGE, &s_temp)
136 && HttpStringToUInt(s_temp, (&i_temp))) {
137 u_temp = static_cast<time_t>(i_temp);
138 corrected_received_age = stdmax(apparent_age, u_temp);
141 size_t response_delay = response_time - request_time;
142 size_t corrected_initial_age = corrected_received_age + response_delay;
143 size_t resident_time = now - response_time;
144 size_t current_age = corrected_initial_age + resident_time;
146 // Compute lifetime of document
148 if (HttpHasAttribute(cache_control, "max-age", &s_temp)) {
149 lifetime = atoi(s_temp.c_str());
150 } else if (t.response.hasHeader(HH_EXPIRES, &s_temp)
151 && HttpDateToSeconds(s_temp, &u_temp)) {
152 lifetime = u_temp - date;
153 } else if (t.response.hasHeader(HH_LAST_MODIFIED, &s_temp)
154 && HttpDateToSeconds(s_temp, &u_temp)) {
155 // TODO: Issue warning 113 if age > 24 hours
156 lifetime = static_cast<size_t>(now - u_temp) / 10;
161 return (lifetime > current_age) ? HCS_FRESH : HCS_STALE;
164 enum HttpValidatorStrength {
170 HttpValidatorStrength
171 HttpRequestValidatorLevel(const HttpRequestData& request) {
172 if (HV_GET != request.verb)
174 return request.hasHeader(HH_RANGE, NULL) ? HVS_STRONG : HVS_WEAK;
177 HttpValidatorStrength
178 HttpResponseValidatorLevel(const HttpResponseData& response) {
180 if (response.hasHeader(HH_ETAG, &value)) {
181 bool is_weak = (strnicmp(value.c_str(), "W/", 2) == 0);
182 return is_weak ? HVS_WEAK : HVS_STRONG;
184 if (response.hasHeader(HH_LAST_MODIFIED, &value)) {
185 time_t last_modified, date;
186 if (HttpDateToSeconds(value, &last_modified)
187 && response.hasHeader(HH_DATE, &value)
188 && HttpDateToSeconds(value, &date)
189 && (last_modified + 60 < date)) {
197 std::string GetCacheID(const HttpRequestData& request) {
199 id.append(ToString(request.verb));
201 request.getAbsoluteUri(&url);
206 } // anonymous namespace
208 //////////////////////////////////////////////////////////////////////
210 //////////////////////////////////////////////////////////////////////
212 bool HttpWriteCacheHeaders(const HttpResponseData* response,
213 StreamInterface* output, size_t* size) {
215 // Write all unknown and end-to-end headers to a cache file
216 for (HttpData::const_iterator it = response->begin();
217 it != response->end(); ++it) {
219 if (FromString(header, it->first) && !HttpHeaderIsEndToEnd(header))
221 length += it->first.length() + 2 + it->second.length() + 2;
224 std::string formatted_header(it->first);
225 formatted_header.append(": ");
226 formatted_header.append(it->second);
227 formatted_header.append("\r\n");
228 StreamResult result = output->WriteAll(formatted_header.data(),
229 formatted_header.length(),
231 if (SR_SUCCESS != result) {
235 if (output && (SR_SUCCESS != output->WriteAll("\r\n", 2, NULL, NULL))) {
244 bool HttpReadCacheHeaders(StreamInterface* input, HttpResponseData* response,
245 HttpData::HeaderCombine combine) {
247 std::string formatted_header;
248 StreamResult result = input->ReadLine(&formatted_header);
249 if ((SR_EOS == result) || (1 == formatted_header.size())) {
252 if (SR_SUCCESS != result) {
255 size_t end_of_name = formatted_header.find(':');
256 if (std::string::npos == end_of_name) {
257 LOG_F(LS_WARNING) << "Malformed cache header";
260 size_t start_of_value = end_of_name + 1;
261 size_t end_of_value = formatted_header.length();
262 while ((start_of_value < end_of_value)
263 && isspace(formatted_header[start_of_value]))
265 while ((start_of_value < end_of_value)
266 && isspace(formatted_header[end_of_value-1]))
268 size_t value_length = end_of_value - start_of_value;
270 std::string name(formatted_header.substr(0, end_of_name));
271 std::string value(formatted_header.substr(start_of_value, value_length));
272 response->changeHeader(name, value, combine);
277 //////////////////////////////////////////////////////////////////////
279 //////////////////////////////////////////////////////////////////////
281 const size_t kDefaultRetries = 1;
282 const size_t kMaxRedirects = 5;
284 HttpClient::HttpClient(const std::string& agent, StreamPool* pool,
285 HttpTransaction* transaction)
286 : agent_(agent), pool_(pool),
287 transaction_(transaction), free_transaction_(false),
288 retries_(kDefaultRetries), attempt_(0), redirects_(0),
289 redirect_action_(REDIRECT_DEFAULT),
290 uri_form_(URI_DEFAULT), cache_(NULL), cache_state_(CS_READY),
293 if (NULL == transaction_) {
294 free_transaction_ = true;
295 transaction_ = new HttpTransaction;
299 HttpClient::~HttpClient() {
301 base_.abort(HE_SHUTDOWN);
303 resolver_->Destroy(false);
306 if (free_transaction_)
310 void HttpClient::reset() {
312 request().clear(true);
313 response().clear(true);
316 base_.abort(HE_OPERATION_CANCELLED);
319 void HttpClient::OnResolveResult(SignalThread* thread) {
320 if (thread != resolver_) {
323 int error = resolver_->error();
324 server_ = resolver_->address();
325 resolver_->Destroy(false);
328 LOG(LS_ERROR) << "Error " << error << " resolving name: "
330 onHttpComplete(HM_CONNECT, HE_CONNECT_FAILED);
336 void HttpClient::StartDNSLookup() {
337 resolver_ = new AsyncResolver();
338 resolver_->set_address(server_);
339 resolver_->SignalWorkDone.connect(this, &HttpClient::OnResolveResult);
343 void HttpClient::set_server(const SocketAddress& address) {
345 // Setting 'Host' here allows it to be overridden before starting the request,
347 request().setHeader(HH_HOST, HttpAddress(server_, false), true);
350 StreamInterface* HttpClient::GetDocumentStream() {
351 return base_.GetDocumentStream();
354 void HttpClient::start() {
355 if (base_.mode() != HM_NONE) {
356 // call reset() to abort an in-progress request
361 ASSERT(!IsCacheActive());
363 if (request().hasHeader(HH_TRANSFER_ENCODING, NULL)) {
364 // Exact size must be known on the client. Instead of using chunked
365 // encoding, wrap data with auto-caching file or memory stream.
372 // If no content has been specified, using length of 0.
373 request().setHeader(HH_CONTENT_LENGTH, "0", false);
375 if (!agent_.empty()) {
376 request().setHeader(HH_USER_AGENT, agent_, false);
379 UriForm uri_form = uri_form_;
380 if (PROXY_HTTPS == proxy_.type) {
381 // Proxies require absolute form
382 uri_form = URI_ABSOLUTE;
383 request().version = HVER_1_0;
384 request().setHeader(HH_PROXY_CONNECTION, "Keep-Alive", false);
386 request().setHeader(HH_CONNECTION, "Keep-Alive", false);
389 if (URI_ABSOLUTE == uri_form) {
390 // Convert to absolute uri form
392 if (request().getAbsoluteUri(&url)) {
393 request().path = url;
395 LOG(LS_WARNING) << "Couldn't obtain absolute uri";
397 } else if (URI_RELATIVE == uri_form) {
398 // Convert to relative uri form
399 std::string host, path;
400 if (request().getRelativeUri(&host, &path)) {
401 request().setHeader(HH_HOST, host);
402 request().path = path;
404 LOG(LS_WARNING) << "Couldn't obtain relative uri";
408 if ((NULL != cache_) && CheckCache()) {
415 void HttpClient::connect() {
417 if (server_.IsUnresolvedIP()) {
421 StreamInterface* stream = pool_->RequestConnectedStream(server_, &stream_err);
422 if (stream == NULL) {
423 ASSERT(0 != stream_err);
424 LOG(LS_ERROR) << "RequestConnectedStream error: " << stream_err;
425 onHttpComplete(HM_CONNECT, HE_CONNECT_FAILED);
427 base_.attach(stream);
428 if (stream->GetState() == SS_OPEN) {
429 base_.send(&transaction_->request);
434 void HttpClient::prepare_get(const std::string& url) {
437 set_server(SocketAddress(purl.host(), purl.port()));
438 request().verb = HV_GET;
439 request().path = purl.full_path();
442 void HttpClient::prepare_post(const std::string& url,
443 const std::string& content_type,
444 StreamInterface* request_doc) {
447 set_server(SocketAddress(purl.host(), purl.port()));
448 request().verb = HV_POST;
449 request().path = purl.full_path();
450 request().setContent(content_type, request_doc);
453 void HttpClient::release() {
454 if (StreamInterface* stream = base_.detach()) {
455 pool_->ReturnConnectedStream(stream);
459 bool HttpClient::ShouldRedirect(std::string* location) const {
460 // TODO: Unittest redirection.
461 if ((REDIRECT_NEVER == redirect_action_)
462 || !HttpCodeIsRedirection(response().scode)
463 || !response().hasHeader(HH_LOCATION, location)
464 || (redirects_ >= kMaxRedirects))
466 return (REDIRECT_ALWAYS == redirect_action_)
467 || (HC_SEE_OTHER == response().scode)
468 || (HV_HEAD == request().verb)
469 || (HV_GET == request().verb);
472 bool HttpClient::BeginCacheFile() {
473 ASSERT(NULL != cache_);
474 ASSERT(CS_READY == cache_state_);
476 std::string id = GetCacheID(request());
477 CacheLock lock(cache_, id, true);
478 if (!lock.IsLocked()) {
479 LOG_F(LS_WARNING) << "Couldn't lock cache";
483 if (HE_NONE != WriteCacheHeaders(id)) {
487 scoped_ptr<StreamInterface> stream(cache_->WriteResource(id, kCacheBody));
489 LOG_F(LS_ERROR) << "Couldn't open body cache";
494 // Let's secretly replace the response document with Folgers Crystals,
495 // er, StreamTap, so that we can mirror the data to our cache.
496 StreamInterface* output = response().document.release();
498 output = new NullStream;
500 StreamTap* tap = new StreamTap(output, stream.release());
501 response().document.reset(tap);
505 HttpError HttpClient::WriteCacheHeaders(const std::string& id) {
506 scoped_ptr<StreamInterface> stream(cache_->WriteResource(id, kCacheHeader));
508 LOG_F(LS_ERROR) << "Couldn't open header cache";
512 if (!HttpWriteCacheHeaders(&transaction_->response, stream.get(), NULL)) {
513 LOG_F(LS_ERROR) << "Couldn't write header cache";
520 void HttpClient::CompleteCacheFile() {
521 // Restore previous response document
522 StreamTap* tap = static_cast<StreamTap*>(response().document.release());
523 response().document.reset(tap->Detach());
526 StreamResult result = tap->GetTapResult(&error);
528 // Delete the tap and cache stream (which completes cache unlock)
531 if (SR_SUCCESS != result) {
532 LOG(LS_ERROR) << "Cache file error: " << error;
533 cache_->DeleteResource(GetCacheID(request()));
537 bool HttpClient::CheckCache() {
538 ASSERT(NULL != cache_);
539 ASSERT(CS_READY == cache_state_);
541 std::string id = GetCacheID(request());
542 if (!cache_->HasResource(id)) {
543 // No cache file available
547 HttpError error = ReadCacheHeaders(id, true);
549 if (HE_NONE == error) {
550 switch (HttpGetCacheState(*transaction_)) {
552 // Cache content is good, read from cache
555 // Cache content may be acceptable. Issue a validation request.
556 if (PrepareValidate()) {
559 // Couldn't validate, fall through.
561 // Cache content is not useable. Issue a regular request.
562 response().clear(false);
567 if (HE_NONE == error) {
568 error = ReadCacheBody(id);
569 cache_state_ = CS_READY;
572 if (HE_CACHE == error) {
573 LOG_F(LS_WARNING) << "Cache failure, continuing with normal request";
574 response().clear(false);
578 SignalHttpClientComplete(this, error);
582 HttpError HttpClient::ReadCacheHeaders(const std::string& id, bool override) {
583 scoped_ptr<StreamInterface> stream(cache_->ReadResource(id, kCacheHeader));
588 HttpData::HeaderCombine combine =
589 override ? HttpData::HC_REPLACE : HttpData::HC_AUTO;
591 if (!HttpReadCacheHeaders(stream.get(), &transaction_->response, combine)) {
592 LOG_F(LS_ERROR) << "Error reading cache headers";
596 response().scode = HC_OK;
600 HttpError HttpClient::ReadCacheBody(const std::string& id) {
601 cache_state_ = CS_READING;
603 HttpError error = HE_NONE;
606 scoped_ptr<StreamInterface> stream(cache_->ReadResource(id, kCacheBody));
607 if (!stream || !stream->GetAvailable(&data_size)) {
608 LOG_F(LS_ERROR) << "Unavailable cache body";
611 error = OnHeaderAvailable(false, false, data_size);
614 if ((HE_NONE == error)
615 && (HV_HEAD != request().verb)
616 && response().document) {
617 char buffer[1024 * 64];
618 StreamResult result = Flow(stream.get(), buffer, ARRAY_SIZE(buffer),
619 response().document.get());
620 if (SR_SUCCESS != result) {
628 bool HttpClient::PrepareValidate() {
629 ASSERT(CS_READY == cache_state_);
630 // At this point, request() contains the pending request, and response()
631 // contains the cached response headers. Reformat the request to validate
632 // the cached content.
633 HttpValidatorStrength vs_required = HttpRequestValidatorLevel(request());
634 HttpValidatorStrength vs_available = HttpResponseValidatorLevel(response());
635 if (vs_available < vs_required) {
639 if (response().hasHeader(HH_ETAG, &value)) {
640 request().addHeader(HH_IF_NONE_MATCH, value);
642 if (response().hasHeader(HH_LAST_MODIFIED, &value)) {
643 request().addHeader(HH_IF_MODIFIED_SINCE, value);
645 response().clear(false);
646 cache_state_ = CS_VALIDATING;
650 HttpError HttpClient::CompleteValidate() {
651 ASSERT(CS_VALIDATING == cache_state_);
653 std::string id = GetCacheID(request());
655 // Merge cached headers with new headers
656 HttpError error = ReadCacheHeaders(id, false);
657 if (HE_NONE != error) {
658 // Rewrite merged headers to cache
659 CacheLock lock(cache_, id);
660 error = WriteCacheHeaders(id);
662 if (HE_NONE != error) {
663 error = ReadCacheBody(id);
668 HttpError HttpClient::OnHeaderAvailable(bool ignore_data, bool chunked,
670 // If we are ignoring the data, this is an intermediate header.
671 // TODO: don't signal intermediate headers. Instead, do all header-dependent
672 // processing now, and either set up the next request, or fail outright.
673 // TODO: by default, only write response documents with a success code.
674 SignalHeaderAvailable(this, !ignore_data, ignore_data ? 0 : data_size);
675 if (!ignore_data && !chunked && (data_size != SIZE_UNKNOWN)
676 && response().document) {
677 // Attempt to pre-allocate space for the downloaded data.
678 if (!response().document->ReserveSize(data_size)) {
686 // HttpBase Implementation
689 HttpError HttpClient::onHttpHeaderComplete(bool chunked, size_t& data_size) {
690 if (CS_VALIDATING == cache_state_) {
691 if (HC_NOT_MODIFIED == response().scode) {
692 return CompleteValidate();
694 // Should we remove conditional headers from request?
695 cache_state_ = CS_READY;
696 cache_->DeleteResource(GetCacheID(request()));
697 // Continue processing response as normal
700 ASSERT(!IsCacheActive());
701 if ((request().verb == HV_HEAD) || !HttpCodeHasBody(response().scode)) {
702 // HEAD requests and certain response codes contain no body
705 if (ShouldRedirect(NULL)
706 || ((HC_PROXY_AUTHENTICATION_REQUIRED == response().scode)
707 && (PROXY_HTTPS == proxy_.type))) {
708 // We're going to issue another request, so ignore the incoming data.
709 base_.set_ignore_data(true);
712 HttpError error = OnHeaderAvailable(base_.ignore_data(), chunked, data_size);
713 if (HE_NONE != error) {
718 && !base_.ignore_data()
719 && HttpShouldCache(*transaction_)) {
720 if (BeginCacheFile()) {
721 cache_state_ = CS_WRITING;
727 void HttpClient::onHttpComplete(HttpMode mode, HttpError err) {
728 if (((HE_DISCONNECTED == err) || (HE_CONNECT_FAILED == err)
729 || (HE_SOCKET_ERROR == err))
730 && (HC_INTERNAL_SERVER_ERROR == response().scode)
731 && (attempt_ < retries_)) {
732 // If the response code has not changed from the default, then we haven't
733 // received anything meaningful from the server, so we are eligible for a
736 if (request().document && !request().document->Rewind()) {
737 // Unable to replay the request document.
744 } else if (err != HE_NONE) {
746 } else if (mode == HM_CONNECT) {
747 base_.send(&transaction_->request);
749 } else if ((mode == HM_SEND) || HttpCodeIsInformational(response().scode)) {
750 // If you're interested in informational headers, catch
751 // SignalHeaderAvailable.
752 base_.recv(&transaction_->response);
755 if (!HttpShouldKeepAlive(response())) {
756 LOG(LS_VERBOSE) << "HttpClient: closing socket";
757 base_.stream()->Close();
759 std::string location;
760 if (ShouldRedirect(&location)) {
761 Url<char> purl(location);
762 set_server(SocketAddress(purl.host(), purl.port()));
763 request().path = purl.full_path();
764 if (response().scode == HC_SEE_OTHER) {
765 request().verb = HV_GET;
766 request().clearHeader(HH_CONTENT_TYPE);
767 request().clearHeader(HH_CONTENT_LENGTH);
768 request().document.reset();
769 } else if (request().document && !request().document->Rewind()) {
770 // Unable to replay the request document.
771 ASSERT(REDIRECT_ALWAYS == redirect_action_);
774 if (err == HE_NONE) {
777 response().clear(false);
782 } else if ((HC_PROXY_AUTHENTICATION_REQUIRED == response().scode)
783 && (PROXY_HTTPS == proxy_.type)) {
784 std::string authorization, auth_method;
785 HttpData::const_iterator begin = response().begin(HH_PROXY_AUTHENTICATE);
786 HttpData::const_iterator end = response().end(HH_PROXY_AUTHENTICATE);
787 for (HttpData::const_iterator it = begin; it != end; ++it) {
788 HttpAuthContext *context = context_.get();
789 HttpAuthResult res = HttpAuthenticate(
790 it->second.data(), it->second.size(),
792 ToString(request().verb), request().path,
793 proxy_.username, proxy_.password,
794 context, authorization, auth_method);
795 context_.reset(context);
796 if (res == HAR_RESPONSE) {
797 request().setHeader(HH_PROXY_AUTHORIZATION, authorization);
798 if (request().document && !request().document->Rewind()) {
801 // Explicitly do not reset the HttpAuthContext
802 response().clear(false);
803 // TODO: Reuse socket when authenticating?
808 } else if (res == HAR_IGNORE) {
809 LOG(INFO) << "Ignoring Proxy-Authenticate: " << auth_method;
817 if (CS_WRITING == cache_state_) {
819 cache_state_ = CS_READY;
820 } else if (CS_READING == cache_state_) {
821 cache_state_ = CS_READY;
824 SignalHttpClientComplete(this, err);
827 void HttpClient::onHttpClosed(HttpError err) {
828 // This shouldn't occur, since we return the stream to the pool upon command
833 //////////////////////////////////////////////////////////////////////
835 //////////////////////////////////////////////////////////////////////
837 HttpClientDefault::HttpClientDefault(SocketFactory* factory,
838 const std::string& agent,
839 HttpTransaction* transaction)
840 : ReuseSocketPool(factory ? factory : Thread::Current()->socketserver()),
841 HttpClient(agent, NULL, transaction) {
845 //////////////////////////////////////////////////////////////////////
847 } // namespace talk_base