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

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: Created 5 years, 11 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(blink::WebURLRequest::RequestContextEventSource); 129 request.setRequestContext(blink::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 CString lastEventIdUtf8 = m_lastEventId.utf8();
133 request.setHTTPHeaderField("Last-Event-ID", AtomicString(reinterpret_cas t<const LChar*>(lastEventIdUtf8.data()), lastEventIdUtf8.length()));
Nate Chapin 2015/01/06 18:23:34 My WTFString-fu is not very good. Can you use Atom
davidben 2015/01/06 19:30:34 I don't think that work. This is an awkward thing
134 }
132 135
133 SecurityOrigin* origin = executionContext.securityOrigin(); 136 SecurityOrigin* origin = executionContext.securityOrigin();
134 137
135 ThreadableLoaderOptions options; 138 ThreadableLoaderOptions options;
136 options.preflightPolicy = PreventPreflight; 139 options.preflightPolicy = PreventPreflight;
137 options.crossOriginRequestPolicy = UseAccessControl; 140 options.crossOriginRequestPolicy = UseAccessControl;
138 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn ectSrcDirective; 141 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn ectSrcDirective;
139 142
140 ResourceLoaderOptions resourceLoaderOptions; 143 ResourceLoaderOptions resourceLoaderOptions;
141 resourceLoaderOptions.allowCredentials = (origin->canRequest(m_url) || m_wit hCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials; 144 resourceLoaderOptions.allowCredentials = (origin->canRequest(m_url) || m_wit hCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 m_data.clear(); 436 m_data.clear();
434 return event.release(); 437 return event.release();
435 } 438 }
436 439
437 void EventSource::trace(Visitor* visitor) 440 void EventSource::trace(Visitor* visitor)
438 { 441 {
439 EventTargetWithInlineData::trace(visitor); 442 EventTargetWithInlineData::trace(visitor);
440 } 443 }
441 444
442 } // namespace blink 445 } // 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