Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Request.cpp

Issue 2783623003: Fetch API: Don't exclude the URL fragment in Request#url (Closed)
Patch Set: address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/fetch.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // Strip off the fragment part of URL. So far, all users of
695 // WebServiceWorkerRequest expect the fragment to be excluded.
696 KURL url(m_request->url());
697 if (m_request->url().hasFragmentIdentifier())
698 url.removeFragmentIdentifier();
699 webRequest.setURL(url);
701 700
702 const FetchHeaderList* headerList = m_headers->headerList(); 701 const FetchHeaderList* headerList = m_headers->headerList();
703 for (size_t i = 0, size = headerList->size(); i < size; ++i) { 702 for (size_t i = 0, size = headerList->size(); i < size; ++i) {
704 const FetchHeaderList::Header& header = headerList->entry(i); 703 const FetchHeaderList::Header& header = headerList->entry(i);
705 webRequest.appendHeader(header.first, header.second); 704 webRequest.appendHeader(header.first, header.second);
706 } 705 }
707 706
708 webRequest.setReferrer( 707 webRequest.setReferrer(
709 m_request->referrerString(), 708 m_request->referrerString(),
710 static_cast<WebReferrerPolicy>(m_request->getReferrerPolicy())); 709 static_cast<WebReferrerPolicy>(m_request->getReferrerPolicy()));
(...skipping 22 matching lines...) Expand all
733 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 732 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
734 } 733 }
735 734
736 DEFINE_TRACE(Request) { 735 DEFINE_TRACE(Request) {
737 Body::trace(visitor); 736 Body::trace(visitor);
738 visitor->trace(m_request); 737 visitor->trace(m_request);
739 visitor->trace(m_headers); 738 visitor->trace(m_headers);
740 } 739 }
741 740
742 } // namespace blink 741 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/fetch/script-tests/fetch.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698