2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "SocketStreamHandle.h"
35 #include "Credential.h"
36 #include "CredentialStorage.h"
38 #include "ProtectionSpace.h"
39 #include "SocketStreamError.h"
40 #include "SocketStreamHandleClient.h"
41 #include <wtf/MainThread.h>
42 #include <wtf/text/WTFString.h>
44 #ifdef BUILDING_ON_LEOPARD
45 #include <SystemConfiguration/SystemConfiguration.h>
49 #include "LoaderRunLoopCF.h"
50 #include <CFNetwork/CFNetwork.h>
51 #include <WebKitSystemInterface/WebKitSystemInterface.h>
53 #include "WebCoreSystemInterface.h"
59 SocketStreamHandle::SocketStreamHandle(const KURL& url, SocketStreamHandleClient* client)
60 : SocketStreamHandleBase(url, client)
61 , m_connectingSubstate(New)
62 , m_connectionType(Unknown)
63 , m_sentStoredCredentials(false)
65 LOG(Network, "SocketStreamHandle %p new client %p", this, m_client);
67 ASSERT(url.protocolIs("ws") || url.protocolIs("wss"));
69 KURL httpsURL(KURL(), "https://" + m_url.host());
70 m_httpsURL.adoptCF(httpsURL.createCFURL());
73 ASSERT(!m_readStream == !m_writeStream);
74 if (!m_readStream) // Doing asynchronous PAC file processing, streams will be created later.
80 void SocketStreamHandle::scheduleStreams()
83 ASSERT(m_writeStream);
85 CFStreamClientContext clientContext = { 0, this, 0, 0, copyCFStreamDescription };
86 // FIXME: Pass specific events we're interested in instead of -1.
87 CFReadStreamSetClient(m_readStream.get(), static_cast<CFOptionFlags>(-1), readStreamCallback, &clientContext);
88 CFWriteStreamSetClient(m_writeStream.get(), static_cast<CFOptionFlags>(-1), writeStreamCallback, &clientContext);
91 CFReadStreamScheduleWithRunLoop(m_readStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
92 CFWriteStreamScheduleWithRunLoop(m_writeStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
94 CFReadStreamScheduleWithRunLoop(m_readStream.get(), CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
95 CFWriteStreamScheduleWithRunLoop(m_writeStream.get(), CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
98 CFReadStreamOpen(m_readStream.get());
99 CFWriteStreamOpen(m_writeStream.get());
101 if (m_pacRunLoopSource)
102 removePACRunLoopSource();
104 m_connectingSubstate = WaitingForConnect;
107 CFStringRef SocketStreamHandle::copyPACExecutionDescription(void*)
109 return CFSTR("WebSocket proxy PAC file execution");
112 struct MainThreadPACCallbackInfo {
113 MainThreadPACCallbackInfo(SocketStreamHandle* handle, CFArrayRef proxyList) : handle(handle), proxyList(proxyList) { }
114 RefPtr<SocketStreamHandle> handle;
115 CFArrayRef proxyList;
118 void SocketStreamHandle::pacExecutionCallback(void* client, CFArrayRef proxyList, CFErrorRef)
120 SocketStreamHandle* handle = static_cast<SocketStreamHandle*>(client);
121 MainThreadPACCallbackInfo info(handle, proxyList);
122 // If we're already on main thread (e.g. on Mac), callOnMainThreadAndWait() will be just a function call.
123 callOnMainThreadAndWait(pacExecutionCallbackMainThread, &info);
126 void SocketStreamHandle::pacExecutionCallbackMainThread(void* invocation)
128 MainThreadPACCallbackInfo* info = static_cast<MainThreadPACCallbackInfo*>(invocation);
129 ASSERT(info->handle->m_connectingSubstate == ExecutingPACFile);
130 // This time, the array won't have PAC as a first entry.
131 info->handle->chooseProxyFromArray(info->proxyList);
132 info->handle->createStreams();
133 info->handle->scheduleStreams();
136 void SocketStreamHandle::executePACFileURL(CFURLRef pacFileURL)
138 // CFNetwork returns an empty proxy array for WebScoket schemes, so use m_httpsURL.
139 CFStreamClientContext clientContext = { 0, this, 0, 0, copyPACExecutionDescription };
140 m_pacRunLoopSource.adoptCF(CFNetworkExecuteProxyAutoConfigurationURL(pacFileURL, m_httpsURL.get(), pacExecutionCallback, &clientContext));
142 CFRunLoopAddSource(loaderRunLoop(), m_pacRunLoopSource.get(), kCFRunLoopDefaultMode);
144 CFRunLoopAddSource(CFRunLoopGetCurrent(), m_pacRunLoopSource.get(), kCFRunLoopCommonModes);
146 m_connectingSubstate = ExecutingPACFile;
149 void SocketStreamHandle::removePACRunLoopSource()
151 ASSERT(m_pacRunLoopSource);
153 CFRunLoopSourceInvalidate(m_pacRunLoopSource.get());
155 CFRunLoopRemoveSource(loaderRunLoop(), m_pacRunLoopSource.get(), kCFRunLoopDefaultMode);
157 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m_pacRunLoopSource.get(), kCFRunLoopCommonModes);
159 m_pacRunLoopSource = 0;
162 void SocketStreamHandle::chooseProxy()
164 #ifndef BUILDING_ON_LEOPARD
165 RetainPtr<CFDictionaryRef> proxyDictionary(AdoptCF, CFNetworkCopySystemProxySettings());
167 // We don't need proxy information often, so there is no need to set up a permanent dynamic store session.
168 RetainPtr<CFDictionaryRef> proxyDictionary(AdoptCF, SCDynamicStoreCopyProxies(0));
171 // SOCKS or HTTPS (AKA CONNECT) proxies are supported.
172 // WebSocket protocol relies on handshake being transferred unchanged, so we need a proxy that will not modify headers.
173 // Since HTTP proxies must add Via headers, they are highly unlikely to work.
174 // Many CONNECT proxies limit connectivity to port 443, so we prefer SOCKS, if configured.
176 if (!proxyDictionary) {
177 m_connectionType = Direct;
181 // CFNetworkCopyProxiesForURL doesn't know about WebSocket schemes, so pretend to use http.
182 // Always use "https" to get HTTPS proxies in result - we'll try to use those for ws:// even though many are configured to reject connections to ports other than 443.
183 RetainPtr<CFArrayRef> proxyArray(AdoptCF, CFNetworkCopyProxiesForURL(m_httpsURL.get(), proxyDictionary.get()));
185 chooseProxyFromArray(proxyArray.get());
188 void SocketStreamHandle::chooseProxyFromArray(CFArrayRef proxyArray)
191 m_connectionType = Direct;
195 CFIndex proxyArrayCount = CFArrayGetCount(proxyArray);
197 // PAC is always the first entry, if present.
198 if (proxyArrayCount) {
199 CFDictionaryRef proxyInfo = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(proxyArray, 0));
200 CFTypeRef proxyType = CFDictionaryGetValue(proxyInfo, kCFProxyTypeKey);
201 if (proxyType && CFGetTypeID(proxyType) == CFStringGetTypeID()) {
202 if (CFEqual(proxyType, kCFProxyTypeAutoConfigurationURL)) {
203 CFTypeRef pacFileURL = CFDictionaryGetValue(proxyInfo, kCFProxyAutoConfigurationURLKey);
204 if (pacFileURL && CFGetTypeID(pacFileURL) == CFURLGetTypeID()) {
205 executePACFileURL(static_cast<CFURLRef>(pacFileURL));
212 CFDictionaryRef chosenProxy = 0;
213 for (CFIndex i = 0; i < proxyArrayCount; ++i) {
214 CFDictionaryRef proxyInfo = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(proxyArray, i));
215 CFTypeRef proxyType = CFDictionaryGetValue(proxyInfo, kCFProxyTypeKey);
216 if (proxyType && CFGetTypeID(proxyType) == CFStringGetTypeID()) {
217 if (CFEqual(proxyType, kCFProxyTypeSOCKS)) {
218 m_connectionType = SOCKSProxy;
219 chosenProxy = proxyInfo;
222 if (CFEqual(proxyType, kCFProxyTypeHTTPS)) {
223 m_connectionType = CONNECTProxy;
224 chosenProxy = proxyInfo;
225 // Keep looking for proxies, as a SOCKS one is preferable.
231 ASSERT(m_connectionType != Unknown);
232 ASSERT(m_connectionType != Direct);
234 CFTypeRef proxyHost = CFDictionaryGetValue(chosenProxy, kCFProxyHostNameKey);
235 CFTypeRef proxyPort = CFDictionaryGetValue(chosenProxy, kCFProxyPortNumberKey);
237 if (proxyHost && CFGetTypeID(proxyHost) == CFStringGetTypeID() && proxyPort && CFGetTypeID(proxyPort) == CFNumberGetTypeID()) {
238 m_proxyHost = static_cast<CFStringRef>(proxyHost);
239 m_proxyPort = static_cast<CFNumberRef>(proxyPort);
244 m_connectionType = Direct;
248 void SocketStreamHandle::createStreams()
250 if (m_connectionType == Unknown)
253 // If it's still unknown, then we're resolving a PAC file asynchronously.
254 if (m_connectionType == Unknown)
257 RetainPtr<CFStringRef> host(AdoptCF, m_url.host().createCFString());
259 // Creating streams to final destination, not to proxy.
260 CFReadStreamRef readStream = 0;
261 CFWriteStreamRef writeStream = 0;
262 CFStreamCreatePairWithSocketToHost(0, host.get(), port(), &readStream, &writeStream);
264 m_readStream.adoptCF(readStream);
265 m_writeStream.adoptCF(writeStream);
267 switch (m_connectionType) {
269 ASSERT_NOT_REACHED();
274 // FIXME: SOCKS5 doesn't do challenge-response, should we try to apply credentials from Keychain right away?
275 // But SOCKS5 credentials don't work at the time of this writing anyway, see <rdar://6776698>.
276 const void* proxyKeys[] = { kCFStreamPropertySOCKSProxyHost, kCFStreamPropertySOCKSProxyPort };
277 const void* proxyValues[] = { m_proxyHost.get(), m_proxyPort.get() };
278 RetainPtr<CFDictionaryRef> connectDictionary(AdoptCF, CFDictionaryCreate(0, proxyKeys, proxyValues, WTF_ARRAY_LENGTH(proxyKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
279 CFReadStreamSetProperty(m_readStream.get(), kCFStreamPropertySOCKSProxy, connectDictionary.get());
283 wkSetCONNECTProxyForStream(m_readStream.get(), m_proxyHost.get(), m_proxyPort.get());
287 if (shouldUseSSL()) {
288 const void* keys[] = { kCFStreamSSLPeerName, kCFStreamSSLLevel };
289 const void* values[] = { host.get(), kCFStreamSocketSecurityLevelNegotiatedSSL };
290 RetainPtr<CFDictionaryRef> settings(AdoptCF, CFDictionaryCreate(0, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
291 CFReadStreamSetProperty(m_readStream.get(), kCFStreamPropertySSLSettings, settings.get());
292 CFWriteStreamSetProperty(m_writeStream.get(), kCFStreamPropertySSLSettings, settings.get());
296 static bool getStoredCONNECTProxyCredentials(const ProtectionSpace& protectionSpace, String& login, String& password)
298 // Try system credential storage first, matching HTTP behavior (CFNetwork only asks the client for password if it couldn't find it in Keychain).
299 Credential storedCredential = CredentialStorage::getFromPersistentStorage(protectionSpace);
300 if (storedCredential.isEmpty())
301 storedCredential = CredentialStorage::get(protectionSpace);
303 if (storedCredential.isEmpty())
306 login = storedCredential.user();
307 password = storedCredential.password();
312 static ProtectionSpaceAuthenticationScheme authenticationSchemeFromAuthenticationMethod(CFStringRef method)
314 if (CFEqual(method, kCFHTTPAuthenticationSchemeBasic))
315 return ProtectionSpaceAuthenticationSchemeHTTPBasic;
316 if (CFEqual(method, kCFHTTPAuthenticationSchemeDigest))
317 return ProtectionSpaceAuthenticationSchemeHTTPDigest;
318 if (CFEqual(method, kCFHTTPAuthenticationSchemeNTLM))
319 return ProtectionSpaceAuthenticationSchemeNTLM;
320 if (CFEqual(method, kCFHTTPAuthenticationSchemeNegotiate))
321 return ProtectionSpaceAuthenticationSchemeNegotiate;
322 ASSERT_NOT_REACHED();
323 return ProtectionSpaceAuthenticationSchemeUnknown;
326 void SocketStreamHandle::addCONNECTCredentials(CFHTTPMessageRef proxyResponse)
328 RetainPtr<CFHTTPAuthenticationRef> authentication(AdoptCF, CFHTTPAuthenticationCreateFromResponse(0, proxyResponse));
330 if (!CFHTTPAuthenticationRequiresUserNameAndPassword(authentication.get())) {
331 // That's all we can offer...
332 m_client->didFailSocketStream(this, SocketStreamError()); // FIXME: Provide a sensible error.
337 CFNumberGetValue(m_proxyPort.get(), kCFNumberIntType, &port);
338 RetainPtr<CFStringRef> methodCF(AdoptCF, CFHTTPAuthenticationCopyMethod(authentication.get()));
339 RetainPtr<CFStringRef> realmCF(AdoptCF, CFHTTPAuthenticationCopyRealm(authentication.get()));
340 ProtectionSpace protectionSpace(String(m_proxyHost.get()), port, ProtectionSpaceProxyHTTPS, String(realmCF.get()), authenticationSchemeFromAuthenticationMethod(methodCF.get()));
343 if (!m_sentStoredCredentials && getStoredCONNECTProxyCredentials(protectionSpace, login, password)) {
344 // Try to apply stored credentials, if we haven't tried those already.
345 RetainPtr<CFStringRef> loginCF(AdoptCF, login.createCFString());
346 RetainPtr<CFStringRef> passwordCF(AdoptCF, password.createCFString());
347 // Creating a temporary request to make CFNetwork apply credentials to it. Unfortunately, this cannot work with NTLM authentication.
348 RetainPtr<CFHTTPMessageRef> dummyRequest(AdoptCF, CFHTTPMessageCreateRequest(0, CFSTR("GET"), m_httpsURL.get(), kCFHTTPVersion1_1));
350 Boolean appliedCredentials = CFHTTPMessageApplyCredentials(dummyRequest.get(), authentication.get(), loginCF.get(), passwordCF.get(), 0);
351 ASSERT_UNUSED(appliedCredentials, appliedCredentials);
353 RetainPtr<CFStringRef> proxyAuthorizationString(AdoptCF, CFHTTPMessageCopyHeaderFieldValue(dummyRequest.get(), CFSTR("Proxy-Authorization")));
355 if (!proxyAuthorizationString) {
356 // Fails e.g. for NTLM auth.
357 m_client->didFailSocketStream(this, SocketStreamError()); // FIXME: Provide a sensible error.
361 // Setting the authorization results in a new connection attempt.
362 wkSetCONNECTProxyAuthorizationForStream(m_readStream.get(), proxyAuthorizationString.get());
363 m_sentStoredCredentials = true;
367 // FIXME: Ask the client if credentials could not be found.
369 m_client->didFailSocketStream(this, SocketStreamError()); // FIXME: Provide a sensible error.
372 CFStringRef SocketStreamHandle::copyCFStreamDescription(void* info)
374 SocketStreamHandle* handle = static_cast<SocketStreamHandle*>(info);
375 return String("WebKit socket stream, " + handle->m_url.string()).createCFString();
378 struct MainThreadEventCallbackInfo {
379 MainThreadEventCallbackInfo(CFStreamEventType type, SocketStreamHandle* handle) : type(type), handle(handle) { }
380 CFStreamEventType type;
381 RefPtr<SocketStreamHandle> handle;
384 void SocketStreamHandle::readStreamCallback(CFReadStreamRef stream, CFStreamEventType type, void* clientCallBackInfo)
386 SocketStreamHandle* handle = static_cast<SocketStreamHandle*>(clientCallBackInfo);
387 ASSERT_UNUSED(stream, stream == handle->m_readStream.get());
389 MainThreadEventCallbackInfo info(type, handle);
390 callOnMainThreadAndWait(readStreamCallbackMainThread, &info);
392 ASSERT(isMainThread());
393 handle->readStreamCallback(type);
397 void SocketStreamHandle::writeStreamCallback(CFWriteStreamRef stream, CFStreamEventType type, void* clientCallBackInfo)
399 SocketStreamHandle* handle = static_cast<SocketStreamHandle*>(clientCallBackInfo);
400 ASSERT_UNUSED(stream, stream == handle->m_writeStream.get());
402 MainThreadEventCallbackInfo info(type, handle);
403 callOnMainThreadAndWait(writeStreamCallbackMainThread, &info);
405 ASSERT(isMainThread());
406 handle->writeStreamCallback(type);
411 void SocketStreamHandle::readStreamCallbackMainThread(void* invocation)
413 MainThreadEventCallbackInfo* info = static_cast<MainThreadEventCallbackInfo*>(invocation);
414 info->handle->readStreamCallback(info->type);
417 void SocketStreamHandle::writeStreamCallbackMainThread(void* invocation)
419 MainThreadEventCallbackInfo* info = static_cast<MainThreadEventCallbackInfo*>(invocation);
420 info->handle->writeStreamCallback(info->type);
422 #endif // PLATFORM(WIN)
424 void SocketStreamHandle::readStreamCallback(CFStreamEventType type)
427 case kCFStreamEventNone:
429 case kCFStreamEventOpenCompleted:
431 case kCFStreamEventHasBytesAvailable: {
432 if (m_connectingSubstate == WaitingForConnect) {
433 if (m_connectionType == CONNECTProxy) {
434 RetainPtr<CFHTTPMessageRef> proxyResponse(AdoptCF, wkCopyCONNECTProxyResponse(m_readStream.get(), m_httpsURL.get()));
435 if (proxyResponse && (407 == CFHTTPMessageGetResponseStatusCode(proxyResponse.get()))) {
436 addCONNECTCredentials(proxyResponse.get());
440 } else if (m_connectingSubstate == WaitingForCredentials)
443 if (m_connectingSubstate == WaitingForConnect) {
444 m_connectingSubstate = Connected;
447 RefPtr<SocketStreamHandle> protect(this); // The client can close the handle, potentially removing the last reference.
448 m_client->didOpenSocketStream(this);
449 if (m_state == Closed)
452 } else if (m_state == Closed)
455 ASSERT(m_state == Open);
456 ASSERT(m_connectingSubstate == Connected);
459 UInt8 localBuffer[1024]; // Used if CFReadStreamGetBuffer couldn't return anything.
460 const UInt8* ptr = CFReadStreamGetBuffer(m_readStream.get(), 0, &length);
462 length = CFReadStreamRead(m_readStream.get(), localBuffer, sizeof(localBuffer));
466 m_client->didReceiveSocketStreamData(this, reinterpret_cast<const char*>(ptr), length);
470 case kCFStreamEventCanAcceptBytes:
471 ASSERT_NOT_REACHED();
473 case kCFStreamEventErrorOccurred: {
474 RetainPtr<CFErrorRef> error(AdoptCF, CFReadStreamCopyError(m_readStream.get()));
475 reportErrorToClient(error.get());
478 case kCFStreamEventEndEncountered:
484 void SocketStreamHandle::writeStreamCallback(CFStreamEventType type)
487 case kCFStreamEventNone:
489 case kCFStreamEventOpenCompleted:
491 case kCFStreamEventHasBytesAvailable:
492 ASSERT_NOT_REACHED();
494 case kCFStreamEventCanAcceptBytes: {
495 // Possibly, a spurious event from CONNECT handshake.
496 if (!CFWriteStreamCanAcceptBytes(m_writeStream.get()))
499 if (m_connectingSubstate == WaitingForCredentials)
502 if (m_connectingSubstate == WaitingForConnect) {
503 m_connectingSubstate = Connected;
506 RefPtr<SocketStreamHandle> protect(this); // The client can close the handle, potentially removing the last reference.
507 m_client->didOpenSocketStream(this);
511 ASSERT(m_state == Open);
512 ASSERT(m_connectingSubstate == Connected);
517 case kCFStreamEventErrorOccurred: {
518 RetainPtr<CFErrorRef> error(AdoptCF, CFWriteStreamCopyError(m_writeStream.get()));
519 reportErrorToClient(error.get());
522 case kCFStreamEventEndEncountered:
523 // FIXME: Currently, we handle closing in read callback, but these can come independently (e.g. a server can stop listening, but keep sending data).
528 void SocketStreamHandle::reportErrorToClient(CFErrorRef error)
530 CFIndex errorCode = CFErrorGetCode(error);
534 if (CFEqual(CFErrorGetDomain(error), kCFErrorDomainOSStatus)) {
535 const char* descriptionOSStatus = GetMacOSStatusCommentString(static_cast<OSStatus>(errorCode));
536 if (descriptionOSStatus && descriptionOSStatus[0] != '\0')
537 description = "OSStatus Error " + String::number(errorCode) + ": " + descriptionOSStatus;
541 if (description.isNull()) {
542 RetainPtr<CFStringRef> descriptionCF(AdoptCF, CFErrorCopyDescription(error));
543 description = String(descriptionCF.get());
546 m_client->didFailSocketStream(this, SocketStreamError(static_cast<int>(errorCode), m_url.string(), description));
549 SocketStreamHandle::~SocketStreamHandle()
551 LOG(Network, "SocketStreamHandle %p dtor", this);
553 ASSERT(!m_pacRunLoopSource);
556 int SocketStreamHandle::platformSend(const char* data, int length)
558 if (!CFWriteStreamCanAcceptBytes(m_writeStream.get()))
561 return CFWriteStreamWrite(m_writeStream.get(), reinterpret_cast<const UInt8*>(data), length);
564 void SocketStreamHandle::platformClose()
566 LOG(Network, "SocketStreamHandle %p platformClose", this);
568 if (m_pacRunLoopSource)
569 removePACRunLoopSource();
571 ASSERT(!m_readStream == !m_writeStream);
573 if (m_connectingSubstate == New || m_connectingSubstate == ExecutingPACFile)
574 m_client->didCloseSocketStream(this);
579 CFReadStreamUnscheduleFromRunLoop(m_readStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
580 CFWriteStreamUnscheduleFromRunLoop(m_writeStream.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
582 CFReadStreamUnscheduleFromRunLoop(m_readStream.get(), CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
583 CFWriteStreamUnscheduleFromRunLoop(m_writeStream.get(), CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
586 CFReadStreamClose(m_readStream.get());
587 CFWriteStreamClose(m_writeStream.get());
592 m_client->didCloseSocketStream(this);
595 void SocketStreamHandle::receivedCredential(const AuthenticationChallenge&, const Credential&)
599 void SocketStreamHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
603 void SocketStreamHandle::receivedCancellation(const AuthenticationChallenge&)
607 unsigned short SocketStreamHandle::port() const
609 if (unsigned short urlPort = m_url.port())
616 } // namespace WebCore