OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome_frame/urlmon_url_request.h" | 5 #include "chrome_frame/urlmon_url_request.h" |
6 | 6 |
7 #include <wininet.h> | 7 #include <wininet.h> |
8 #include <urlmon.h> | 8 #include <urlmon.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome_frame/bind_context_info.h" | 17 #include "chrome_frame/bind_context_info.h" |
18 #include "chrome_frame/chrome_frame_activex_base.h" | 18 #include "chrome_frame/chrome_frame_activex_base.h" |
19 #include "chrome_frame/extra_system_apis.h" | 19 #include "chrome_frame/extra_system_apis.h" |
20 #include "chrome_frame/html_utils.h" | 20 #include "chrome_frame/html_utils.h" |
21 #include "chrome_frame/urlmon_url_request_private.h" | 21 #include "chrome_frame/urlmon_url_request_private.h" |
22 #include "chrome_frame/urlmon_upload_data_stream.h" | 22 #include "chrome_frame/urlmon_upload_data_stream.h" |
23 #include "chrome_frame/utils.h" | 23 #include "chrome_frame/utils.h" |
24 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 25 #include "net/http/http_response_headers.h" |
25 #include "net/http/http_util.h" | 26 #include "net/http/http_util.h" |
26 #include "net/http/http_response_headers.h" | |
27 | 27 |
28 UrlmonUrlRequest::UrlmonUrlRequest() | 28 UrlmonUrlRequest::UrlmonUrlRequest() |
29 : pending_read_size_(0), | 29 : pending_read_size_(0), |
30 headers_received_(false), | 30 headers_received_(false), |
31 calling_delegate_(0), | 31 calling_delegate_(0), |
32 thread_(NULL), | 32 thread_(NULL), |
33 parent_window_(NULL), | 33 parent_window_(NULL), |
34 privileged_mode_(false), | 34 privileged_mode_(false), |
35 pending_(false), | 35 pending_(false), |
36 is_expecting_download_(true), | 36 is_expecting_download_(true), |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 << ": Aborting connection to URL:" | 560 << ": Aborting connection to URL:" |
561 << url | 561 << url |
562 << " as the binding has been aborted"; | 562 << " as the binding has been aborted"; |
563 return E_ABORT; | 563 return E_ABORT; |
564 } | 564 } |
565 | 565 |
566 HRESULT hr = S_OK; | 566 HRESULT hr = S_OK; |
567 | 567 |
568 std::string new_headers; | 568 std::string new_headers; |
569 if (post_data_len() > 0) { | 569 if (post_data_len() > 0) { |
570 // Tack on the Content-Length header since when using an IStream type | 570 if (is_chunked_upload()) { |
571 // STGMEDIUM, it looks like it doesn't get set for us :( | 571 new_headers = base::StringPrintf("Transfer-Encoding: chunked\r\n"); |
572 new_headers = base::StringPrintf( | 572 } else { |
573 "Content-Length: %s\r\n", | 573 // Tack on the Content-Length header since when using an IStream type |
574 base::Int64ToString(post_data_len()).c_str()); | 574 // STGMEDIUM, it looks like it doesn't get set for us :( |
| 575 new_headers = base::StringPrintf( |
| 576 "Content-Length: %s\r\n", |
| 577 base::Int64ToString(post_data_len()).c_str()); |
| 578 } |
575 } | 579 } |
576 | 580 |
577 if (!extra_headers().empty()) { | 581 if (!extra_headers().empty()) { |
578 // TODO(robertshield): We may need to sanitize headers on POST here. | 582 // TODO(robertshield): We may need to sanitize headers on POST here. |
579 new_headers += extra_headers(); | 583 new_headers += extra_headers(); |
580 } | 584 } |
581 | 585 |
582 if (!referrer().empty()) { | 586 if (!referrer().empty()) { |
583 // Referrer is famously misspelled in HTTP: | 587 // Referrer is famously misspelled in HTTP: |
584 new_headers += base::StringPrintf("Referer: %s\r\n", referrer().c_str()); | 588 new_headers += base::StringPrintf("Referer: %s\r\n", referrer().c_str()); |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 privacy_info_.privacy_records[UTF8ToWide(url)]; | 1242 privacy_info_.privacy_records[UTF8ToWide(url)]; |
1239 | 1243 |
1240 privacy_entry.flags |= flags; | 1244 privacy_entry.flags |= flags; |
1241 privacy_entry.policy_ref = UTF8ToWide(policy_ref); | 1245 privacy_entry.policy_ref = UTF8ToWide(policy_ref); |
1242 | 1246 |
1243 if (fire_privacy_event && IsWindow(notification_window_)) { | 1247 if (fire_privacy_event && IsWindow(notification_window_)) { |
1244 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, | 1248 PostMessage(notification_window_, WM_FIRE_PRIVACY_CHANGE_NOTIFICATION, 1, |
1245 0); | 1249 0); |
1246 } | 1250 } |
1247 } | 1251 } |
OLD | NEW |