OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "modules/fetch/Request.h" | 5 #include "modules/fetch/Request.h" |
6 | 6 |
7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/loader/ThreadableLoader.h" | 10 #include "core/loader/ThreadableLoader.h" |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 : Request(scriptState, request, Headers::create(request->headerList())) { | 486 : Request(scriptState, request, Headers::create(request->headerList())) { |
487 m_headers->setGuard(Headers::RequestGuard); | 487 m_headers->setGuard(Headers::RequestGuard); |
488 } | 488 } |
489 | 489 |
490 String Request::method() const { | 490 String Request::method() const { |
491 // "The method attribute's getter must return request's method." | 491 // "The method attribute's getter must return request's method." |
492 return m_request->method(); | 492 return m_request->method(); |
493 } | 493 } |
494 | 494 |
495 KURL Request::url() const { | 495 KURL Request::url() const { |
496 // The url attribute's getter must return request's url, serialized with the | 496 return m_request->url(); |
497 // exclude fragment flag set. | |
498 if (!m_request->url().hasFragmentIdentifier()) | |
499 return m_request->url(); | |
500 KURL url(m_request->url()); | |
501 url.removeFragmentIdentifier(); | |
502 return url; | |
503 } | 497 } |
504 | 498 |
505 String Request::context() const { | 499 String Request::context() const { |
506 // "The context attribute's getter must return request's context" | 500 // "The context attribute's getter must return request's context" |
507 switch (m_request->context()) { | 501 switch (m_request->context()) { |
508 case WebURLRequest::RequestContextUnspecified: | 502 case WebURLRequest::RequestContextUnspecified: |
509 return ""; | 503 return ""; |
510 case WebURLRequest::RequestContextAudio: | 504 case WebURLRequest::RequestContextAudio: |
511 return "audio"; | 505 return "audio"; |
512 case WebURLRequest::RequestContextBeacon: | 506 case WebURLRequest::RequestContextBeacon: |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 } | 683 } |
690 | 684 |
691 bool Request::hasBody() const { | 685 bool Request::hasBody() const { |
692 return bodyBuffer(); | 686 return bodyBuffer(); |
693 } | 687 } |
694 | 688 |
695 void Request::populateWebServiceWorkerRequest( | 689 void Request::populateWebServiceWorkerRequest( |
696 WebServiceWorkerRequest& webRequest) const { | 690 WebServiceWorkerRequest& webRequest) const { |
697 webRequest.setMethod(method()); | 691 webRequest.setMethod(method()); |
698 webRequest.setRequestContext(m_request->context()); | 692 webRequest.setRequestContext(m_request->context()); |
699 // This strips off the fragment part. | 693 |
700 webRequest.setURL(url()); | 694 // Strips off the fragment part of URL. |
falken
2017/03/31 06:40:49
nit: "Strips" -> "Strip" is more consistent with t
yiyix
2017/03/31 07:24:02
Done.
| |
695 KURL url(m_request->url()); | |
696 if (m_request->url().hasFragmentIdentifier()) | |
697 url.removeFragmentIdentifier(); | |
698 webRequest.setURL(url); | |
701 | 699 |
702 const FetchHeaderList* headerList = m_headers->headerList(); | 700 const FetchHeaderList* headerList = m_headers->headerList(); |
703 for (size_t i = 0, size = headerList->size(); i < size; ++i) { | 701 for (size_t i = 0, size = headerList->size(); i < size; ++i) { |
704 const FetchHeaderList::Header& header = headerList->entry(i); | 702 const FetchHeaderList::Header& header = headerList->entry(i); |
705 webRequest.appendHeader(header.first, header.second); | 703 webRequest.appendHeader(header.first, header.second); |
706 } | 704 } |
707 | 705 |
708 webRequest.setReferrer( | 706 webRequest.setReferrer( |
709 m_request->referrerString(), | 707 m_request->referrerString(), |
710 static_cast<WebReferrerPolicy>(m_request->getReferrerPolicy())); | 708 static_cast<WebReferrerPolicy>(m_request->getReferrerPolicy())); |
(...skipping 22 matching lines...) Expand all Loading... | |
733 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); | 731 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); |
734 } | 732 } |
735 | 733 |
736 DEFINE_TRACE(Request) { | 734 DEFINE_TRACE(Request) { |
737 Body::trace(visitor); | 735 Body::trace(visitor); |
738 visitor->trace(m_request); | 736 visitor->trace(m_request); |
739 visitor->trace(m_headers); | 737 visitor->trace(m_headers); |
740 } | 738 } |
741 | 739 |
742 } // namespace blink | 740 } // namespace blink |
OLD | NEW |