OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags, | 464 STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags, |
465 BINDINFO *bind_info) { | 465 BINDINFO *bind_info) { |
466 DCHECK(worker_thread_ != NULL); | 466 DCHECK(worker_thread_ != NULL); |
467 DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id()); | 467 DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id()); |
468 | 468 |
469 if ((bind_info == NULL) || (bind_info->cbSize == 0) || (bind_flags == NULL)) | 469 if ((bind_info == NULL) || (bind_info->cbSize == 0) || (bind_flags == NULL)) |
470 return E_INVALIDARG; | 470 return E_INVALIDARG; |
471 | 471 |
472 *bind_flags = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; | 472 *bind_flags = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; |
| 473 |
| 474 bool upload_data = false; |
| 475 |
473 if (LowerCaseEqualsASCII(method(), "get")) { | 476 if (LowerCaseEqualsASCII(method(), "get")) { |
474 bind_info->dwBindVerb = BINDVERB_GET; | 477 bind_info->dwBindVerb = BINDVERB_GET; |
475 } else if (LowerCaseEqualsASCII(method(), "post")) { | 478 } else if (LowerCaseEqualsASCII(method(), "post")) { |
476 bind_info->dwBindVerb = BINDVERB_POST; | 479 bind_info->dwBindVerb = BINDVERB_POST; |
| 480 upload_data = true; |
| 481 } else if (LowerCaseEqualsASCII(method(), "put")) { |
| 482 bind_info->dwBindVerb = BINDVERB_PUT; |
| 483 upload_data = true; |
| 484 } else { |
| 485 NOTREACHED() << "Unknown HTTP method."; |
| 486 status_.set_status(URLRequestStatus::FAILED); |
| 487 status_.set_os_error(net::ERR_METHOD_NOT_SUPPORTED); |
| 488 EndRequest(); |
| 489 return E_FAIL; |
| 490 } |
477 | 491 |
478 // Bypass caching proxies on POSTs and avoid writing responses to POST | 492 if (upload_data) { |
479 // requests to the browser's cache. | 493 // Bypass caching proxies on POSTs and PUTs and avoid writing responses to |
| 494 // these requests to the browser's cache |
480 *bind_flags |= BINDF_GETNEWESTVERSION | BINDF_NOWRITECACHE | | 495 *bind_flags |= BINDF_GETNEWESTVERSION | BINDF_NOWRITECACHE | |
481 BINDF_PRAGMA_NO_CACHE; | 496 BINDF_PRAGMA_NO_CACHE; |
482 | 497 |
483 // Initialize the STGMEDIUM. | 498 // Initialize the STGMEDIUM. |
484 memset(&bind_info->stgmedData, 0, sizeof(STGMEDIUM)); | 499 memset(&bind_info->stgmedData, 0, sizeof(STGMEDIUM)); |
485 bind_info->grfBindInfoF = 0; | 500 bind_info->grfBindInfoF = 0; |
486 bind_info->szCustomVerb = NULL; | 501 bind_info->szCustomVerb = NULL; |
487 | 502 |
488 if (get_upload_data(&bind_info->stgmedData.pstm) == S_OK) { | 503 if (get_upload_data(&bind_info->stgmedData.pstm) == S_OK) { |
489 bind_info->stgmedData.tymed = TYMED_ISTREAM; | 504 bind_info->stgmedData.tymed = TYMED_ISTREAM; |
490 DLOG(INFO) << " Obj: " << std::hex << this << " POST request with " | 505 DLOG(INFO) << " Obj: " << std::hex << this << " " << method() |
491 << Int64ToString(post_data_len()) << " bytes"; | 506 << " request with " << Int64ToString(post_data_len()) |
| 507 << " bytes"; |
492 } else { | 508 } else { |
493 DLOG(INFO) << " Obj: " << std::hex << this | 509 DLOG(INFO) << " Obj: " << std::hex << this |
494 << "POST request with no data!"; | 510 << "POST request with no data!"; |
495 } | 511 } |
496 } else { | |
497 NOTREACHED() << "Unknown HTTP method."; | |
498 status_.set_status(URLRequestStatus::FAILED); | |
499 status_.set_os_error(net::ERR_INVALID_URL); | |
500 EndRequest(); | |
501 return E_FAIL; | |
502 } | 512 } |
503 | 513 |
504 return S_OK; | 514 return S_OK; |
505 } | 515 } |
506 | 516 |
507 STDMETHODIMP UrlmonUrlRequest::OnDataAvailable(DWORD flags, DWORD size, | 517 STDMETHODIMP UrlmonUrlRequest::OnDataAvailable(DWORD flags, DWORD size, |
508 FORMATETC* formatetc, | 518 FORMATETC* formatetc, |
509 STGMEDIUM* storage) { | 519 STGMEDIUM* storage) { |
510 DCHECK(worker_thread_ != NULL); | 520 DCHECK(worker_thread_ != NULL); |
511 DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id()); | 521 DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id()); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 ret = net::ERR_ACCESS_DENIED; | 1082 ret = net::ERR_ACCESS_DENIED; |
1073 break; | 1083 break; |
1074 | 1084 |
1075 default: | 1085 default: |
1076 DLOG(WARNING) | 1086 DLOG(WARNING) |
1077 << StringPrintf("TODO: translate HRESULT 0x%08X to net::Error", hr); | 1087 << StringPrintf("TODO: translate HRESULT 0x%08X to net::Error", hr); |
1078 break; | 1088 break; |
1079 } | 1089 } |
1080 return ret; | 1090 return ret; |
1081 } | 1091 } |
OLD | NEW |