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(); |