aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 16:47:12 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 16:48:03 -0700
commit41575b982c386e17d5f1228b50fb9fd309c981cc (patch)
tree120ab1505d891643cd33efa24c49101e134a8f65 /src
parentb4feb33df98f5b0d50dc65174ce1161b1fadd5cb (diff)
downloadbun-41575b982c386e17d5f1228b50fb9fd309c981cc.tar.gz
bun-41575b982c386e17d5f1228b50fb9fd309c981cc.tar.zst
bun-41575b982c386e17d5f1228b50fb9fd309c981cc.zip
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/http/websocket_http_client.zig2
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocket.cpp6
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocketHandshake.cpp485
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocketHandshake.h102
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocketStream.cpp10
-rw-r--r--src/javascript/jsc/bindings/webcore/WebSocketStream.h117
6 files changed, 3 insertions, 719 deletions
diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig
index 52d64b8a2..85adedf66 100644
--- a/src/http/websocket_http_client.zig
+++ b/src/http/websocket_http_client.zig
@@ -1123,7 +1123,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type {
// closing frame data is text only.
// 2 byte close code
- if (data.len > 2) {
+ if (data.len > 2 and receive_body_remain >= 2) {
_ = this.consume(data[2..receive_body_remain], receive_body_remain - 2, .Text, true);
data = data[receive_body_remain..];
}
diff --git a/src/javascript/jsc/bindings/webcore/WebSocket.cpp b/src/javascript/jsc/bindings/webcore/WebSocket.cpp
index d9ffd7278..3fe881192 100644
--- a/src/javascript/jsc/bindings/webcore/WebSocket.cpp
+++ b/src/javascript/jsc/bindings/webcore/WebSocket.cpp
@@ -31,7 +31,6 @@
#include "config.h"
#include "WebSocket.h"
-#include "WebSocketStream.h"
#include "headers.h"
// #include "Blob.h"
#include "CloseEvent.h"
@@ -798,8 +797,7 @@ void WebSocket::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
}
if (auto* context = scriptExecutionContext()) {
-
- context->postTask([this, message_ = message, protectedThis = Ref { *this }](ScriptExecutionContext& context) {
+ context->postTask([this, binaryData = binaryData, protectedThis = Ref { *this }](ScriptExecutionContext& context) {
ASSERT(scriptExecutionContext());
protectedThis->dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData.data(), binaryData.size()), m_url.string()));
});
@@ -1039,7 +1037,7 @@ void WebSocket::didFailWithErrorCode(int32_t code)
break;
}
- // failed_to_allocate_memory
+ // failed_to_allocate_memory
case 18: {
auto message = MAKE_STATIC_STRING_IMPL("Failed to allocate memory");
didReceiveMessageError(message);
diff --git a/src/javascript/jsc/bindings/webcore/WebSocketHandshake.cpp b/src/javascript/jsc/bindings/webcore/WebSocketHandshake.cpp
deleted file mode 100644
index 90482d668..000000000
--- a/src/javascript/jsc/bindings/webcore/WebSocketHandshake.cpp
+++ /dev/null
@@ -1,485 +0,0 @@
-// /*
-// * Copyright (C) 2011 Google Inc. All rights reserved.
-// * Copyright (C) Research In Motion Limited 2011. All rights reserved.
-// * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
-// *
-// * Redistribution and use in source and binary forms, with or without
-// * modification, are permitted provided that the following conditions are
-// * met:
-// *
-// * * Redistributions of source code must retain the above copyright
-// * notice, this list of conditions and the following disclaimer.
-// * * Redistributions in binary form must reproduce the above
-// * copyright notice, this list of conditions and the following disclaimer
-// * in the documentation and/or other materials provided with the
-// * distribution.
-// * * Neither the name of Google Inc. nor the names of its
-// * contributors may be used to endorse or promote products derived from
-// * this software without specific prior written permission.
-// *
-// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// */
-
-// #include "config.h"
-// #include "WebSocketHandshake.h"
-
-// #include "HTTPHeaderMap.h"
-// #include "HTTPHeaderNames.h"
-// #include "HTTPHeaderValues.h"
-// #include "HTTPParsers.h"
-// #include "ScriptExecutionContext.h"
-// #include <wtf/URL.h>
-// #include "WebSocket.h"
-// #include <wtf/ASCIICType.h>
-// #include <wtf/CryptographicallyRandomNumber.h>
-// #include <wtf/SHA1.h>
-// #include <wtf/StdLibExtras.h>
-// #include <wtf/StringExtras.h>
-// #include <wtf/Vector.h>
-// #include <wtf/text/Base64.h>
-// #include <wtf/text/CString.h>
-// #include <wtf/text/StringToIntegerConversion.h>
-// #include <wtf/text/StringView.h>
-// #include <wtf/text/WTFString.h>
-// #include <wtf/unicode/CharacterNames.h>
-
-// namespace WebCore {
-
-// static String resourceName(const URL& url)
-// {
-// auto path = url.path();
-// auto result = makeString(
-// path,
-// path.isEmpty() ? "/" : "",
-// url.queryWithLeadingQuestionMark());
-// ASSERT(!result.isEmpty());
-// ASSERT(!result.contains(' '));
-// return result;
-// }
-
-// static String hostName(const URL& url, bool secure)
-// {
-// ASSERT(url.protocolIs("wss") == secure);
-// if (url.port() && ((!secure && url.port().value() != 80) || (secure && url.port().value() != 443)))
-// return makeString(asASCIILowercase(url.host()), ':', url.port().value());
-// return url.host().convertToASCIILowercase();
-// }
-
-// static constexpr size_t maxInputSampleSize = 128;
-// static String trimInputSample(const uint8_t* p, size_t length)
-// {
-// if (length <= maxInputSampleSize)
-// return String(p, length);
-// return makeString(StringView(p, length).left(maxInputSampleSize), horizontalEllipsis);
-// }
-
-// static String generateSecWebSocketKey()
-// {
-// static const size_t nonceSize = 16;
-// unsigned char key[nonceSize];
-// cryptographicallyRandomValues(key, nonceSize);
-// return base64EncodeToString(key, nonceSize);
-// }
-
-// String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocketKey)
-// {
-// constexpr uint8_t webSocketKeyGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
-// SHA1 sha1;
-// CString keyData = secWebSocketKey.ascii();
-// sha1.addBytes(keyData.dataAsUInt8Ptr(), keyData.length());
-// sha1.addBytes(webSocketKeyGUID, std::size(webSocketKeyGUID) - 1);
-// SHA1::Digest hash;
-// sha1.computeHash(hash);
-// return base64EncodeToString(hash.data(), SHA1::hashSize);
-// }
-
-// WebSocketHandshake::WebSocketHandshake(const URL& url, const String& protocol, const String& userAgent, const String& clientOrigin, bool allowCookies, bool isAppInitiated)
-// : m_url(url)
-// , m_clientProtocol(protocol)
-// , m_secure(m_url.protocolIs("wss"))
-// , m_mode(Incomplete)
-// , m_userAgent(userAgent)
-// , m_clientOrigin(clientOrigin)
-// , m_allowCookies(allowCookies)
-// , m_isAppInitiated(isAppInitiated)
-// {
-// m_secWebSocketKey = generateSecWebSocketKey();
-// m_expectedAccept = getExpectedWebSocketAccept(m_secWebSocketKey);
-// }
-
-// WebSocketHandshake::~WebSocketHandshake() = default;
-
-// const URL& WebSocketHandshake::url() const
-// {
-// return m_url;
-// }
-
-// // FIXME: Return type should just be String, not const String.
-// const String WebSocketHandshake::host() const
-// {
-// return m_url.host().convertToASCIILowercase();
-// }
-
-// const String& WebSocketHandshake::clientProtocol() const
-// {
-// return m_clientProtocol;
-// }
-
-// void WebSocketHandshake::setClientProtocol(const String& protocol)
-// {
-// m_clientProtocol = protocol;
-// }
-
-// bool WebSocketHandshake::secure() const
-// {
-// return m_secure;
-// }
-
-// String WebSocketHandshake::clientLocation() const
-// {
-// return makeString(m_secure ? "wss" : "ws", "://", hostName(m_url, m_secure), resourceName(m_url));
-// }
-
-// CString WebSocketHandshake::clientHandshakeMessage() const
-// {
-// // Keep the following consistent with clientHandshakeRequest just below.
-
-// // Cookies are not retrieved in the WebContent process. Instead, a proxy object is
-// // added in the handshake, and is exchanged for actual cookies in the Network process.
-
-// // Add no-cache headers to avoid a compatibility issue. There are some proxies that
-// // rewrite "Connection: upgrade" to "Connection: close" in the response if a request
-// // doesn't contain these headers.
-
-// auto extensions = m_extensionDispatcher.createHeaderValue();
-// }
-
-// void WebSocketHandshake::reset()
-// {
-// m_mode = Incomplete;
-// }
-
-// int WebSocketHandshake::readServerHandshake(const uint8_t* header, size_t len)
-// {
-// m_mode = Incomplete;
-// int statusCode;
-// AtomString statusText;
-// int lineLength = readStatusLine(header, len, statusCode, statusText);
-// if (lineLength == -1)
-// return -1;
-// if (statusCode == -1) {
-// m_mode = Failed; // m_failureReason is set inside readStatusLine().
-// return len;
-// }
-// // LOG(Network, "WebSocketHandshake %p readServerHandshake() Status code is %d", this, statusCode);
-
-// m_serverHandshakeResponse = ResourceResponse();
-// m_serverHandshakeResponse.setHTTPStatusCode(statusCode);
-// m_serverHandshakeResponse.setHTTPStatusText(statusText);
-
-// if (statusCode != 101) {
-// m_mode = Failed;
-// m_failureReason = makeString("Unexpected response code: ", statusCode);
-// return len;
-// }
-// m_mode = Normal;
-// if (!memmem(header, len, "\r\n\r\n", 4)) {
-// // Just hasn't been received fully yet.
-// m_mode = Incomplete;
-// return -1;
-// }
-// auto p = readHTTPHeaders(header + lineLength, header + len);
-// if (!p) {
-// // LOG(Network, "WebSocketHandshake %p readServerHandshake() readHTTPHeaders() failed", this);
-// m_mode = Failed; // m_failureReason is set inside readHTTPHeaders().
-// return len;
-// }
-// if (!checkResponseHeaders()) {
-// // LOG(Network, "WebSocketHandshake %p readServerHandshake() checkResponseHeaders() failed", this);
-// m_mode = Failed;
-// return p - header;
-// }
-
-// m_mode = Connected;
-// return p - header;
-// }
-
-// WebSocketHandshake::Mode WebSocketHandshake::mode() const
-// {
-// return m_mode;
-// }
-
-// String WebSocketHandshake::failureReason() const
-// {
-// return m_failureReason;
-// }
-
-// String WebSocketHandshake::serverWebSocketProtocol() const
-// {
-// return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::SecWebSocketProtocol);
-// }
-
-// String WebSocketHandshake::serverSetCookie() const
-// {
-// return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::SetCookie);
-// }
-
-// String WebSocketHandshake::serverUpgrade() const
-// {
-// return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::Upgrade);
-// }
-
-// String WebSocketHandshake::serverConnection() const
-// {
-// return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::Connection);
-// }
-
-// String WebSocketHandshake::serverWebSocketAccept() const
-// {
-// return m_serverHandshakeResponse.httpHeaderFields().get(HTTPHeaderName::SecWebSocketAccept);
-// }
-
-// void WebSocketHandshake::addExtensionProcessor(std::unique_ptr<WebSocketExtensionProcessor> processor)
-// {
-// m_extensionDispatcher.addProcessor(WTFMove(processor));
-// }
-
-// URL WebSocketHandshake::httpURLForAuthenticationAndCookies() const
-// {
-// URL url = m_url.isolatedCopy();
-// bool couldSetProtocol = url.setProtocol(m_secure ? "https" : "http");
-// ASSERT_UNUSED(couldSetProtocol, couldSetProtocol);
-// return url;
-// }
-
-// // https://tools.ietf.org/html/rfc6455#section-4.1
-// // "The HTTP version MUST be at least 1.1."
-// static inline bool headerHasValidHTTPVersion(StringView httpStatusLine)
-// {
-// constexpr char preamble[] = "HTTP/";
-// if (!httpStatusLine.startsWith(preamble))
-// return false;
-
-// // Check that there is a version number which should be at least three characters after "HTTP/"
-// unsigned preambleLength = strlen(preamble);
-// if (httpStatusLine.length() < preambleLength + 3)
-// return false;
-
-// auto dotPosition = httpStatusLine.find('.', preambleLength);
-// if (dotPosition == notFound)
-// return false;
-
-// auto majorVersion = parseInteger<int>(httpStatusLine.substring(preambleLength, dotPosition - preambleLength));
-// if (!majorVersion)
-// return false;
-
-// unsigned minorVersionLength;
-// unsigned charactersLeftAfterDotPosition = httpStatusLine.length() - dotPosition;
-// for (minorVersionLength = 1; minorVersionLength < charactersLeftAfterDotPosition; minorVersionLength++) {
-// if (!isASCIIDigit(httpStatusLine[dotPosition + minorVersionLength]))
-// break;
-// }
-// auto minorVersion = parseInteger<int>(httpStatusLine.substring(dotPosition + 1, minorVersionLength));
-// if (!minorVersion)
-// return false;
-
-// return (*majorVersion >= 1 && *minorVersion >= 1) || *majorVersion >= 2;
-// }
-
-// // Returns the header length (including "\r\n"), or -1 if we have not received enough data yet.
-// // If the line is malformed or the status code is not a 3-digit number,
-// // statusCode and statusText will be set to -1 and a null string, respectively.
-// int WebSocketHandshake::readStatusLine(const uint8_t* header, size_t headerLength, int& statusCode, AtomString& statusText)
-// {
-// // Arbitrary size limit to prevent the server from sending an unbounded
-// // amount of data with no newlines and forcing us to buffer it all.
-// static const int maximumLength = 1024;
-
-// statusCode = -1;
-// statusText = nullAtom();
-
-// const uint8_t* space1 = nullptr;
-// const uint8_t* space2 = nullptr;
-// const uint8_t* p;
-// size_t consumedLength;
-
-// for (p = header, consumedLength = 0; consumedLength < headerLength; p++, consumedLength++) {
-// if (*p == ' ') {
-// if (!space1)
-// space1 = p;
-// else if (!space2)
-// space2 = p;
-// } else if (*p == '\0') {
-// // The caller isn't prepared to deal with null bytes in status
-// // line. WebSockets specification doesn't prohibit this, but HTTP
-// // does, so we'll just treat this as an error.
-// m_failureReason = "Status line contains embedded null"_s;
-// return p + 1 - header;
-// } else if (!isASCII(*p)) {
-// m_failureReason = "Status line contains non-ASCII character"_s;
-// return p + 1 - header;
-// } else if (*p == '\n')
-// break;
-// }
-// if (consumedLength == headerLength)
-// return -1; // We have not received '\n' yet.
-
-// auto end = p + 1;
-// int lineLength = end - header;
-// if (lineLength > maximumLength) {
-// m_failureReason = "Status line is too long"_s;
-// return maximumLength;
-// }
-
-// // The line must end with "\r\n".
-// if (lineLength < 2 || *(end - 2) != '\r') {
-// m_failureReason = "Status line does not end with CRLF"_s;
-// return lineLength;
-// }
-
-// if (!space1 || !space2) {
-// m_failureReason = makeString("No response code found: ", trimInputSample(header, lineLength - 2));
-// return lineLength;
-// }
-
-// StringView httpStatusLine(header, space1 - header);
-// if (!headerHasValidHTTPVersion(httpStatusLine)) {
-// m_failureReason = makeString("Invalid HTTP version string: ", httpStatusLine);
-// return lineLength;
-// }
-
-// StringView statusCodeString(space1 + 1, space2 - space1 - 1);
-// if (statusCodeString.length() != 3) // Status code must consist of three digits.
-// return lineLength;
-// for (int i = 0; i < 3; ++i) {
-// if (!isASCIIDigit(statusCodeString[i])) {
-// m_failureReason = makeString("Invalid status code: ", statusCodeString);
-// return lineLength;
-// }
-// }
-
-// statusCode = parseInteger<int>(statusCodeString).value();
-// statusText = AtomString(space2 + 1, end - space2 - 3); // Exclude "\r\n".
-// return lineLength;
-// }
-
-// const uint8_t* WebSocketHandshake::readHTTPHeaders(const uint8_t* start, const uint8_t* end)
-// {
-// StringView name;
-// String value;
-// bool sawSecWebSocketExtensionsHeaderField = false;
-// bool sawSecWebSocketAcceptHeaderField = false;
-// bool sawSecWebSocketProtocolHeaderField = false;
-// auto p = start;
-// for (; p < end; p++) {
-// size_t consumedLength = parseHTTPHeader(p, end - p, m_failureReason, name, value);
-// if (!consumedLength)
-// return nullptr;
-// p += consumedLength;
-
-// // Stop once we consumed an empty line.
-// if (name.isEmpty())
-// break;
-
-// HTTPHeaderName headerName;
-// if (!findHTTPHeaderName(name, headerName)) {
-// // Evidence in the wild shows that services make use of custom headers in the handshake
-// m_serverHandshakeResponse.addUncommonHTTPHeaderField(name.toString(), value);
-// continue;
-// }
-
-// // https://tools.ietf.org/html/rfc7230#section-3.2.4
-// // "Newly defined header fields SHOULD limit their field values to US-ASCII octets."
-// if ((headerName == HTTPHeaderName::SecWebSocketExtensions
-// || headerName == HTTPHeaderName::SecWebSocketAccept
-// || headerName == HTTPHeaderName::SecWebSocketProtocol)
-// && !value.isAllASCII()) {
-// m_failureReason = makeString(name, " header value should only contain ASCII characters");
-// return nullptr;
-// }
-
-// if (headerName == HTTPHeaderName::SecWebSocketExtensions) {
-// if (sawSecWebSocketExtensionsHeaderField) {
-// m_failureReason = "The Sec-WebSocket-Extensions header must not appear more than once in an HTTP response"_s;
-// return nullptr;
-// }
-// sawSecWebSocketExtensionsHeaderField = true;
-// } else {
-// if (headerName == HTTPHeaderName::SecWebSocketAccept) {
-// if (sawSecWebSocketAcceptHeaderField) {
-// m_failureReason = "The Sec-WebSocket-Accept header must not appear more than once in an HTTP response"_s;
-// return nullptr;
-// }
-// sawSecWebSocketAcceptHeaderField = true;
-// } else if (headerName == HTTPHeaderName::SecWebSocketProtocol) {
-// if (sawSecWebSocketProtocolHeaderField) {
-// m_failureReason = "The Sec-WebSocket-Protocol header must not appear more than once in an HTTP response"_s;
-// return nullptr;
-// }
-// sawSecWebSocketProtocolHeaderField = true;
-// }
-
-// m_serverHandshakeResponse.addHTTPHeaderField(headerName, value);
-// }
-// }
-// return p;
-// }
-
-// bool WebSocketHandshake::checkResponseHeaders()
-// {
-// const String& serverWebSocketProtocol = this->serverWebSocketProtocol();
-// const String& serverUpgrade = this->serverUpgrade();
-// const String& serverConnection = this->serverConnection();
-// const String& serverWebSocketAccept = this->serverWebSocketAccept();
-
-// if (serverUpgrade.isNull()) {
-// m_failureReason = "Error during WebSocket handshake: 'Upgrade' header is missing"_s;
-// return false;
-// }
-// if (serverConnection.isNull()) {
-// m_failureReason = "Error during WebSocket handshake: 'Connection' header is missing"_s;
-// return false;
-// }
-// if (serverWebSocketAccept.isNull()) {
-// m_failureReason = "Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing"_s;
-// return false;
-// }
-
-// if (!equalLettersIgnoringASCIICase(serverUpgrade, "websocket"_s)) {
-// m_failureReason = "Error during WebSocket handshake: 'Upgrade' header value is not 'WebSocket'"_s;
-// return false;
-// }
-// if (!equalLettersIgnoringASCIICase(serverConnection, "upgrade"_s)) {
-// m_failureReason = "Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'"_s;
-// return false;
-// }
-
-// if (serverWebSocketAccept != m_expectedAccept) {
-// m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Accept mismatch"_s;
-// return false;
-// }
-// if (!serverWebSocketProtocol.isNull()) {
-// if (m_clientProtocol.isEmpty()) {
-// m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch"_s;
-// return false;
-// }
-// Vector<String> result = m_clientProtocol.split(StringView { WebSocket::subprotocolSeparator() });
-// if (!result.contains(serverWebSocketProtocol)) {
-// m_failureReason = "Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch"_s;
-// return false;
-// }
-// }
-// return true;
-// }
-
-// } // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/WebSocketHandshake.h b/src/javascript/jsc/bindings/webcore/WebSocketHandshake.h
deleted file mode 100644
index 1cefe2e60..000000000
--- a/src/javascript/jsc/bindings/webcore/WebSocketHandshake.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// /*
-// * Copyright (C) 2011 Google Inc. All rights reserved.
-// * Copyright (C) 2021 Apple Inc. All rights reserved.
-// *
-// * Redistribution and use in source and binary forms, with or without
-// * modification, are permitted provided that the following conditions are
-// * met:
-// *
-// * * Redistributions of source code must retain the above copyright
-// * notice, this list of conditions and the following disclaimer.
-// * * Redistributions in binary form must reproduce the above
-// * copyright notice, this list of conditions and the following disclaimer
-// * in the documentation and/or other materials provided with the
-// * distribution.
-// * * Neither the name of Google Inc. nor the names of its
-// * contributors may be used to endorse or promote products derived from
-// * this software without specific prior written permission.
-// *
-// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// */
-
-// #pragma once
-
-// #include <wtf/URL.h>
-// #include <wtf/WeakPtr.h>
-// #include <wtf/text/WTFString.h>
-
-// namespace WebCore {
-
-// class WebSocketHandshake {
-
-// public:
-// enum Mode {
-// Incomplete,
-// Normal,
-// Failed,
-// Connected
-// };
-// WebSocketHandshake(const URL&, const String& protocol);
-// ~WebSocketHandshake() {}
-
-// const URL& url() const;
-// void setURL(const URL&);
-// URL httpURLForAuthenticationAndCookies() const;
-// const String host() const;
-
-// const String& clientProtocol() const;
-// void setClientProtocol(const String&);
-
-// bool secure() const;
-
-// String clientLocation() const;
-
-// CString clientHandshakeMessage() const;
-
-// void reset();
-
-// int readServerHandshake(const uint8_t* header, size_t len);
-// Mode mode() const;
-// String failureReason() const; // Returns a string indicating the reason of failure if mode() == Failed.
-
-// String serverWebSocketProtocol() const;
-// String serverSetCookie() const;
-// String serverUpgrade() const;
-// String serverConnection() const;
-// String serverWebSocketAccept() const;
-// String acceptedExtensions() const;
-
-// // void addExtensionProcessor(std::unique_ptr<WebSocketExtensionProcessor>);
-
-// static String getExpectedWebSocketAccept(const String& secWebSocketKey);
-
-// private:
-// int readStatusLine(const uint8_t* header, size_t headerLength, int& statusCode, AtomString& statusText);
-
-// // Reads all headers except for the two predefined ones.
-// const uint8_t* readHTTPHeaders(const uint8_t* start, const uint8_t* end);
-// void processHeaders();
-// bool checkResponseHeaders();
-
-// URL m_url;
-// String m_clientProtocol;
-// bool m_secure;
-
-// Mode m_mode;
-// String m_failureReason;
-
-// String m_secWebSocketKey;
-// String m_expectedAccept;
-// };
-
-// } // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp b/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp
deleted file mode 100644
index c318130b8..000000000
--- a/src/javascript/jsc/bindings/webcore/WebSocketStream.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "root.h"
-#include "headers.h"
-
-#include "WebSocketStream.h"
-#include "ScriptExecutionContext.h"
-#include <uws/src/App.h>
-#include <uws/uSockets/src/libusockets.h>
-namespace WebCore {
-
-} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/webcore/WebSocketStream.h b/src/javascript/jsc/bindings/webcore/WebSocketStream.h
deleted file mode 100644
index 78c142864..000000000
--- a/src/javascript/jsc/bindings/webcore/WebSocketStream.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-#include "root.h"
-
-#include "wtf/text/StringImpl.h"
-#include "wtf/text/StringView.h"
-#include "wtf/text/WTFString.h"
-#include "wtf/URL.h"
-#include "wtf/Vector.h"
-#include "wtf/Function.h"
-#include "ScriptExecutionContext.h"
-#include "headers.h"
-
-namespace uWS {
-template<bool, bool, typename>
-class WebSocket;
-
-template<bool, bool, typename>
-class WebSocketContext;
-}
-
-struct us_socket_context_t;
-struct us_socket_t;
-struct us_loop_t;
-
-namespace WebCore {
-
-class ScriptExecutionContext;
-
-enum ClosingHandshakeCompletionStatus {
- ClosingHandshakeIncomplete,
- ClosingHandshakeComplete
-};
-
-class WebSocket;
-
-// This class expects the stream to already be connected & ready to go
-template<bool isSSL, bool isServer>
-class WebSocketStreamBase final {
-public:
- using WebSocketStreamPtr = WebCore::WebSocket*;
- using WebSocketImpl = uWS::WebSocket<isSSL, isServer, WebSocketStreamPtr>;
- using WebSocketStreamImpl = WebSocketStreamBase<isSSL, isServer>;
- using WebSocketContext = uWS::WebSocketContext<isSSL, isServer, WebSocketStreamPtr>;
-
- ~WebSocketStreamBase();
- void didConnect();
- void didReceiveMessage(String&&);
- void didReceiveBinaryData(Vector<uint8_t>&&);
- void didReceiveMessageError(String&&);
- void didUpdateBufferedAmount(unsigned bufferedAmount);
- void didStartClosingHandshake();
-
- void sendData(const uint8_t* data, size_t length, Function<void(bool)>);
- void close(); // Disconnect after all data in buffer are sent.
- void disconnect();
- size_t bufferedAmount() const;
-
- void close(int code, const String& reason); // Start closing handshake.
- void fail(String&& reason);
- enum CloseEventCode {
- CloseEventCodeNotSpecified = -1,
- CloseEventCodeNormalClosure = 1000,
- CloseEventCodeGoingAway = 1001,
- CloseEventCodeProtocolError = 1002,
- CloseEventCodeUnsupportedData = 1003,
- CloseEventCodeFrameTooLarge = 1004,
- CloseEventCodeNoStatusRcvd = 1005,
- CloseEventCodeAbnormalClosure = 1006,
- CloseEventCodeInvalidFramePayloadData = 1007,
- CloseEventCodePolicyViolation = 1008,
- CloseEventCodeMessageTooBig = 1009,
- CloseEventCodeMandatoryExt = 1010,
- CloseEventCodeInternalError = 1011,
- CloseEventCodeTLSHandshake = 1015,
- CloseEventCodeMinimumUserDefined = 3000,
- CloseEventCodeMaximumUserDefined = 4999
- };
-
- void didClose(unsigned unhandledBufferedAmount, ClosingHandshakeCompletionStatus, unsigned short code, const String& reason);
- void didUpgradeURL();
-
- WebSocketStreamBase()
- {
- }
-};
-
-} // namespace WebCore