OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |