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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventSource.cpp
diff --git a/Source/core/page/EventSource.cpp b/Source/core/page/EventSource.cpp
index e05e348067117be7cfd9389a63474d1f28cd5dfc..7b4f9b1566492696deb141ff61f45c39089508d7 100644
--- a/Source/core/page/EventSource.cpp
+++ b/Source/core/page/EventSource.cpp
@@ -127,8 +127,12 @@ void EventSource::connect()
request.setHTTPHeaderField("Accept", "text/event-stream");
request.setHTTPHeaderField("Cache-Control", "no-cache");
request.setRequestContext(WebURLRequest::RequestContextEventSource);
- if (!m_lastEventId.isEmpty())
- request.setHTTPHeaderField("Last-Event-ID", m_lastEventId);
+ if (!m_lastEventId.isEmpty()) {
+ // HTTP headers are Latin-1 byte strings, but the Last-Event-ID header is encoded as UTF-8.
+ // TODO(davidben): This should be captured in the type of setHTTPHeaderField's arguments.
+ CString lastEventIdUtf8 = m_lastEventId.utf8();
+ request.setHTTPHeaderField("Last-Event-ID", AtomicString(reinterpret_cast<const LChar*>(lastEventIdUtf8.data()), lastEventIdUtf8.length()));
+ }
SecurityOrigin* origin = executionContext.securityOrigin();
« 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