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

Side by Side Diff: Source/core/page/EventSource.cpp

Issue 836823002: Encode the Last-Event-ID header in EventSource as UTF-8. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 4 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 | « LayoutTests/http/tests/eventsource/workers/eventsource-reconnect-expected.txt ('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 /* 1 /*
2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved. 2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved.
3 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ASSERT(m_state == CONNECTING); 120 ASSERT(m_state == CONNECTING);
121 ASSERT(!m_requestInFlight); 121 ASSERT(!m_requestInFlight);
122 ASSERT(executionContext()); 122 ASSERT(executionContext());
123 123
124 ExecutionContext& executionContext = *this->executionContext(); 124 ExecutionContext& executionContext = *this->executionContext();
125 ResourceRequest request(m_url); 125 ResourceRequest request(m_url);
126 request.setHTTPMethod("GET"); 126 request.setHTTPMethod("GET");
127 request.setHTTPHeaderField("Accept", "text/event-stream"); 127 request.setHTTPHeaderField("Accept", "text/event-stream");
128 request.setHTTPHeaderField("Cache-Control", "no-cache"); 128 request.setHTTPHeaderField("Cache-Control", "no-cache");
129 request.setRequestContext(WebURLRequest::RequestContextEventSource); 129 request.setRequestContext(WebURLRequest::RequestContextEventSource);
130 if (!m_lastEventId.isEmpty()) 130 if (!m_lastEventId.isEmpty()) {
131 request.setHTTPHeaderField("Last-Event-ID", m_lastEventId); 131 // HTTP headers are Latin-1 byte strings, but the Last-Event-ID header i s encoded as UTF-8.
132 // TODO(davidben): This should be captured in the type of setHTTPHeaderF ield's arguments.
133 CString lastEventIdUtf8 = m_lastEventId.utf8();
134 request.setHTTPHeaderField("Last-Event-ID", AtomicString(reinterpret_cas t<const LChar*>(lastEventIdUtf8.data()), lastEventIdUtf8.length()));
135 }
132 136
133 SecurityOrigin* origin = executionContext.securityOrigin(); 137 SecurityOrigin* origin = executionContext.securityOrigin();
134 138
135 ThreadableLoaderOptions options; 139 ThreadableLoaderOptions options;
136 options.preflightPolicy = PreventPreflight; 140 options.preflightPolicy = PreventPreflight;
137 options.crossOriginRequestPolicy = UseAccessControl; 141 options.crossOriginRequestPolicy = UseAccessControl;
138 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn ectSrcDirective; 142 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn ectSrcDirective;
139 143
140 ResourceLoaderOptions resourceLoaderOptions; 144 ResourceLoaderOptions resourceLoaderOptions;
141 resourceLoaderOptions.allowCredentials = (origin->canRequestNoSuborigin(m_ur l) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials; 145 resourceLoaderOptions.allowCredentials = (origin->canRequestNoSuborigin(m_ur l) || m_withCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 return event.release(); 449 return event.release();
446 } 450 }
447 451
448 DEFINE_TRACE(EventSource) 452 DEFINE_TRACE(EventSource)
449 { 453 {
450 RefCountedGarbageCollectedEventTargetWithInlineData::trace(visitor); 454 RefCountedGarbageCollectedEventTargetWithInlineData::trace(visitor);
451 ActiveDOMObject::trace(visitor); 455 ActiveDOMObject::trace(visitor);
452 } 456 }
453 457
454 } // namespace blink 458 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/eventsource/workers/eventsource-reconnect-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698