Title: [150161] trunk/Source
Revision
150161
Author
[email protected]
Date
2013-05-15 17:36:28 -0700 (Wed, 15 May 2013)

Log Message

Move HTTPRequest class to WebKit2
https://bugs.webkit.org/show_bug.cgi?id=116192

Reviewed by Darin Adler.

Source/WebCore:

HTTPRequest is only used by the "remote inspector" feature in WebKit2,
so there's no need to have it in WebCore.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit2:

Move HTTPRequest to WebKit2 and put it in the WebKit namespace.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* UIProcess/InspectorServer/HTTPRequest.cpp: Renamed from Source/WebCore/platform/network/HTTPRequest.cpp.
* UIProcess/InspectorServer/HTTPRequest.h: Renamed from Source/WebCore/platform/network/HTTPRequest.h.
* UIProcess/InspectorServer/WebInspectorServer.cpp:
* UIProcess/InspectorServer/WebInspectorServer.h:
(WebInspectorServer):
* UIProcess/InspectorServer/WebSocketServerClient.h:
(WebKit::WebSocketServerClient::didReceiveUnrecognizedHTTPRequest):
(WebKit::WebSocketServerClient::didReceiveWebSocketUpgradeHTTPRequest):
(WebKit::WebSocketServerClient::didEstablishWebSocketConnection):
* UIProcess/InspectorServer/WebSocketServerConnection.cpp:
* UIProcess/InspectorServer/WebSocketServerConnection.h:
(WebKit):
(WebSocketServerConnection):

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (150160 => 150161)


--- trunk/Source/WebCore/CMakeLists.txt	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-05-16 00:36:28 UTC (rev 150161)
@@ -2041,7 +2041,6 @@
     platform/network/FormData.cpp
     platform/network/HTTPHeaderMap.cpp
     platform/network/HTTPParsers.cpp
-    platform/network/HTTPRequest.cpp
     platform/network/MIMEHeader.cpp
     platform/network/NetworkStateNotifier.cpp
     platform/network/ParsedContentType.cpp

Modified: trunk/Source/WebCore/ChangeLog (150160 => 150161)


--- trunk/Source/WebCore/ChangeLog	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/ChangeLog	2013-05-16 00:36:28 UTC (rev 150161)
@@ -1,3 +1,21 @@
+2013-05-15  Anders Carlsson  <[email protected]>
+
+        Move HTTPRequest class to WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=116192
+
+        Reviewed by Darin Adler.
+
+        HTTPRequest is only used by the "remote inspector" feature in WebKit2,
+        so there's no need to have it in WebCore.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2013-05-15  Oliver Hunt  <[email protected]>
 
         RefCountedArray needs to use vector initialisers for its backing store

Modified: trunk/Source/WebCore/GNUmakefile.list.am (150160 => 150161)


--- trunk/Source/WebCore/GNUmakefile.list.am	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2013-05-16 00:36:28 UTC (rev 150161)
@@ -5880,8 +5880,6 @@
 	Source/WebCore/platform/network/HTTPHeaderMap.h \
 	Source/WebCore/platform/network/HTTPParsers.cpp \
 	Source/WebCore/platform/network/HTTPParsers.h \
-	Source/WebCore/platform/network/HTTPRequest.cpp \
-	Source/WebCore/platform/network/HTTPRequest.h \
 	Source/WebCore/platform/network/MIMEHeader.cpp \
 	Source/WebCore/platform/network/MIMEHeader.h \
 	Source/WebCore/platform/network/NetworkingContext.h \

Modified: trunk/Source/WebCore/Target.pri (150160 => 150161)


--- trunk/Source/WebCore/Target.pri	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/Target.pri	2013-05-16 00:36:28 UTC (rev 150161)
@@ -1091,7 +1091,6 @@
     platform/network/FormDataBuilder.cpp \
     platform/network/HTTPHeaderMap.cpp \
     platform/network/HTTPParsers.cpp \
-    platform/network/HTTPRequest.cpp \
     platform/network/MIMEHeader.cpp \
     platform/network/NetworkStateNotifier.cpp \
     platform/network/NetworkStorageSessionStub.cpp \
@@ -2328,7 +2327,6 @@
     platform/network/FormData.h \
     platform/network/HTTPHeaderMap.h \
     platform/network/HTTPParsers.h \
-    platform/network/HTTPRequest.h \
     platform/network/HTTPStatusCodes.h \
     platform/network/MIMESniffing.h \
     platform/network/NetworkStorageSession.h \

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (150160 => 150161)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2013-05-16 00:36:28 UTC (rev 150161)
@@ -32986,14 +32986,6 @@
 					>
 				</File>
 				<File
-					RelativePath="..\platform\network\HTTPRequest.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\platform\network\HTTPRequest.h"
-					>
-				</File>
-				<File
 					RelativePath="..\platform\network\MIMEHeader.cpp"
 					>
 				</File>

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (150160 => 150161)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2013-05-16 00:36:28 UTC (rev 150161)
@@ -4615,7 +4615,6 @@
     <ClCompile Include="..\platform\network\FormDataBuilder.cpp" />
     <ClCompile Include="..\platform\network\HTTPHeaderMap.cpp" />
     <ClCompile Include="..\platform\network\HTTPParsers.cpp" />
-    <ClCompile Include="..\platform\network\HTTPRequest.cpp" />
     <ClCompile Include="..\platform\network\MIMEHeader.cpp" />
     <ClCompile Include="..\platform\network\NetworkStateNotifier.cpp" />
     <ClCompile Include="..\platform\network\NetworkStorageSessionStub.cpp">

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (150160 => 150161)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2013-05-16 00:36:28 UTC (rev 150161)
@@ -1869,9 +1869,6 @@
     <ClCompile Include="..\platform\network\HTTPParsers.cpp">
       <Filter>platform\network</Filter>
     </ClCompile>
-    <ClCompile Include="..\platform\network\HTTPRequest.cpp">
-      <Filter>platform\network</Filter>
-    </ClCompile>
     <ClCompile Include="..\platform\network\MIMEHeader.cpp">
       <Filter>platform\network</Filter>
     </ClCompile>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (150160 => 150161)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-05-16 00:36:28 UTC (rev 150161)
@@ -3404,8 +3404,6 @@
 		A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */ = {isa = PBXBuildFile; fileRef = A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */; };
 		A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; };
 		A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		A5D214B112E905510090F370 /* HTTPRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5D214AE12E905510090F370 /* HTTPRequest.cpp */; };
-		A5D214B212E905510090F370 /* HTTPRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A5D214AF12E905510090F370 /* HTTPRequest.h */; };
 		A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */; };
 		A6148A6712E41D940044A784 /* DOMHTMLKeygenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */; };
 		A6148A6812E41D940044A784 /* DOMHTMLKeygenElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */; };
@@ -9892,8 +9890,6 @@
 		A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = "<group>"; };
 		A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCocoa.h; path = cocoa/KeyEventCocoa.h; sourceTree = "<group>"; };
 		A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventCocoa.mm; path = cocoa/KeyEventCocoa.mm; sourceTree = "<group>"; };
-		A5D214AE12E905510090F370 /* HTTPRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPRequest.cpp; sourceTree = "<group>"; };
-		A5D214AF12E905510090F370 /* HTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPRequest.h; sourceTree = "<group>"; };
 		A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLKeygenElementInternal.h; sourceTree = "<group>"; };
 		A6148A6512E41D940044A784 /* DOMHTMLKeygenElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMHTMLKeygenElement.h; sourceTree = "<group>"; };
 		A6148A6612E41D940044A784 /* DOMHTMLKeygenElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLKeygenElement.mm; sourceTree = "<group>"; };
@@ -14540,8 +14536,6 @@
 				514C765C0CE923A1007EF3CD /* HTTPHeaderMap.h */,
 				514C765D0CE923A1007EF3CD /* HTTPParsers.cpp */,
 				514C765E0CE923A1007EF3CD /* HTTPParsers.h */,
-				A5D214AE12E905510090F370 /* HTTPRequest.cpp */,
-				A5D214AF12E905510090F370 /* HTTPRequest.h */,
 				37DDCD9213844FD50008B793 /* MIMEHeader.cpp */,
 				37DDCD9313844FD50008B793 /* MIMEHeader.h */,
 				628D214B12131ED10055DCFC /* NetworkingContext.h */,
@@ -22118,7 +22112,6 @@
 				977B387A122883E900B81FF8 /* HTMLViewSourceParser.h in Headers */,
 				514C76710CE923A1007EF3CD /* HTTPHeaderMap.h in Headers */,
 				514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
-				A5D214B212E905510090F370 /* HTTPRequest.h in Headers */,
 				375CD232119D43C800A2A859 /* Hyphenation.h in Headers */,
 				B275356E0B053814002CE64F /* Icon.h in Headers */,
 				97E4029013A696ED00913D67 /* IconController.h in Headers */,
@@ -25301,7 +25294,6 @@
 				977B3879122883E900B81FF8 /* HTMLViewSourceParser.cpp in Sources */,
 				0B8C56D40F28627F000502E1 /* HTTPHeaderMap.cpp in Sources */,
 				514C76720CE923A1007EF3CD /* HTTPParsers.cpp in Sources */,
-				A5D214B112E905510090F370 /* HTTPRequest.cpp in Sources */,
 				371A67CB11C6C7DB00047B8B /* HyphenationCF.cpp in Sources */,
 				375CD23B119D44EA00A2A859 /* HyphenationMac.mm in Sources */,
 				97E4028F13A696ED00913D67 /* IconController.cpp in Sources */,

Deleted: trunk/Source/WebCore/platform/network/HTTPRequest.cpp (150160 => 150161)


--- trunk/Source/WebCore/platform/network/HTTPRequest.cpp	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/platform/network/HTTPRequest.cpp	2013-05-16 00:36:28 UTC (rev 150161)
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2011 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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 "HTTPRequest.h"
-
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-PassRefPtr<HTTPRequest> HTTPRequest::parseHTTPRequestFromBuffer(const char* data, size_t length, String& failureReason)
-{
-    if (!length) {
-        failureReason = "No data to parse.";
-        return 0;
-    }
-
-    // Request we will be building.
-    RefPtr<HTTPRequest> request = HTTPRequest::create();
-
-    // Advance a pointer through the data as needed.
-    const char* pos = data;
-    size_t remainingLength = length;
-
-    // 1. Parse Method + URL.
-    size_t requestLineLength = request->parseRequestLine(pos, remainingLength, failureReason);
-    if (!requestLineLength)
-        return 0;
-    pos += requestLineLength;
-    remainingLength -= requestLineLength;
-
-    // 2. Parse HTTP Headers.
-    size_t headersLength = request->parseHeaders(pos, remainingLength, failureReason);
-    if (!headersLength)
-        return 0;
-    pos += headersLength;
-    remainingLength -= headersLength;
-
-    // 3. Parse HTTP Data.
-    size_t dataLength = request->parseRequestBody(pos, remainingLength);
-    pos += dataLength;
-    remainingLength -= dataLength;
-
-    // We should have processed the entire input.
-    ASSERT(!remainingLength);
-    return request.release();
-}
-
-size_t HTTPRequest::parseRequestLine(const char* data, size_t length, String& failureReason)
-{
-    String url;
-    size_t result = parseHTTPRequestLine(data, length, failureReason, m_requestMethod, url, m_httpVersion);
-    m_url = KURL(KURL(), url);
-    return result;
-}
-
-size_t HTTPRequest::parseHeaders(const char* data, size_t length, String& failureReason)
-{
-    const char* p = data;
-    const char* end = data + length;
-    AtomicString name;
-    String value;
-    for (; p < data + length; p++) {
-        size_t consumedLength = parseHTTPHeader(p, end - p, failureReason, name, value);
-        if (!consumedLength)
-            return 0;
-        p += consumedLength;
-        if (name.isEmpty())
-            break;
-        m_headerFields.add(name, value);
-    }
-    return p - data;
-}
-
-size_t HTTPRequest::parseRequestBody(const char* data, size_t length)
-{
-    return parseHTTPRequestBody(data, length, m_body);
-}
-
-HTTPRequest::HTTPRequest()
-    : m_httpVersion(Unknown)
-{
-}
-
-HTTPRequest::HTTPRequest(const String& requestMethod, const KURL& url, HTTPVersion version)
-    : m_url(url)
-    , m_httpVersion(version)
-    , m_requestMethod(requestMethod)
-{
-}
-
-HTTPRequest::~HTTPRequest()
-{
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/platform/network/HTTPRequest.h (150160 => 150161)


--- trunk/Source/WebCore/platform/network/HTTPRequest.h	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebCore/platform/network/HTTPRequest.h	2013-05-16 00:36:28 UTC (rev 150161)
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc.  All rights reserved.
- * Copyright (C) 2011 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.
- */
-
-#ifndef HTTPRequest_h
-#define HTTPRequest_h
-
-#include "HTTPHeaderMap.h"
-#include "HTTPParsers.h"
-#include "KURL.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class HTTPRequest : public RefCounted<HTTPRequest> {
-public:
-    static PassRefPtr<HTTPRequest> create() { return adoptRef(new HTTPRequest()); }
-    static PassRefPtr<HTTPRequest> create(const String& requestMethod, const KURL& url, HTTPVersion version) { return adoptRef(new HTTPRequest(requestMethod, url, version)); }
-    static PassRefPtr<HTTPRequest> parseHTTPRequestFromBuffer(const char* data, size_t length, String& failureReason);
-    virtual ~HTTPRequest();
-
-    String requestMethod() const { return m_requestMethod; }
-    void setRequestMethod(const String& method) { m_requestMethod = method; }
-
-    KURL url() const { return m_url; }
-    void setURL(const KURL& url) { m_url = url; }
-
-    const Vector<unsigned char>& body() const { return m_body; }
-
-    const HTTPHeaderMap& headerFields() const { return m_headerFields; }
-    void addHeaderField(const AtomicString& name, const String& value) { m_headerFields.add(name, value); }
-    void addHeaderField(const char* name, const String& value) { m_headerFields.add(name, value); }
-
-protected:
-    HTTPRequest();
-    HTTPRequest(const String& requestMethod, const KURL&, HTTPVersion);
-
-    // Parsing helpers.
-    size_t parseRequestLine(const char* data, size_t length, String& failureReason);
-    size_t parseHeaders(const char* data, size_t length, String& failureReason);
-    size_t parseRequestBody(const char* data, size_t length);
-
-    KURL m_url;
-    HTTPVersion m_httpVersion;
-    String m_requestMethod;
-    HTTPHeaderMap m_headerFields;
-    Vector<unsigned char> m_body;
-};
-
-} // namespace WebCore
-
-#endif // HTTPRequest_h

Modified: trunk/Source/WebKit2/CMakeLists.txt (150160 => 150161)


--- trunk/Source/WebKit2/CMakeLists.txt	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/CMakeLists.txt	2013-05-16 00:36:28 UTC (rev 150161)
@@ -359,6 +359,7 @@
     UIProcess/Downloads/DownloadProxy.cpp
     UIProcess/Downloads/DownloadProxyMap.cpp
 
+    UIProcess/InspectorServer/HTTPRequest.cpp
     UIProcess/InspectorServer/WebInspectorServer.cpp
     UIProcess/InspectorServer/WebSocketServer.cpp
     UIProcess/InspectorServer/WebSocketServerConnection.cpp

Modified: trunk/Source/WebKit2/ChangeLog (150160 => 150161)


--- trunk/Source/WebKit2/ChangeLog	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-16 00:36:28 UTC (rev 150161)
@@ -1,3 +1,29 @@
+2013-05-15  Anders Carlsson  <[email protected]>
+
+        Move HTTPRequest class to WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=116192
+
+        Reviewed by Darin Adler.
+
+        Move HTTPRequest to WebKit2 and put it in the WebKit namespace.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * UIProcess/InspectorServer/HTTPRequest.cpp: Renamed from Source/WebCore/platform/network/HTTPRequest.cpp.
+        * UIProcess/InspectorServer/HTTPRequest.h: Renamed from Source/WebCore/platform/network/HTTPRequest.h.
+        * UIProcess/InspectorServer/WebInspectorServer.cpp:
+        * UIProcess/InspectorServer/WebInspectorServer.h:
+        (WebInspectorServer):
+        * UIProcess/InspectorServer/WebSocketServerClient.h:
+        (WebKit::WebSocketServerClient::didReceiveUnrecognizedHTTPRequest):
+        (WebKit::WebSocketServerClient::didReceiveWebSocketUpgradeHTTPRequest):
+        (WebKit::WebSocketServerClient::didEstablishWebSocketConnection):
+        * UIProcess/InspectorServer/WebSocketServerConnection.cpp:
+        * UIProcess/InspectorServer/WebSocketServerConnection.h:
+        (WebKit):
+        (WebSocketServerConnection):
+
 2013-05-15  Arnaud Renevier  <[email protected]>
 
         [GTK] [WebKit2] enable displaying console.log messages to system console

Modified: trunk/Source/WebKit2/GNUmakefile.list.am (150160 => 150161)


--- trunk/Source/WebKit2/GNUmakefile.list.am	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/GNUmakefile.list.am	2013-05-16 00:36:28 UTC (rev 150161)
@@ -979,6 +979,8 @@
 	Source/WebKit2/UIProcess/WebTextCheckerClient.h \
 	Source/WebKit2/UIProcess/WebUIClient.cpp \
 	Source/WebKit2/UIProcess/WebUIClient.h \
+	Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp \
+	Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h \
 	Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp \
 	Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h \
 	Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.cpp \

Modified: trunk/Source/WebKit2/Target.pri (150160 => 150161)


--- trunk/Source/WebKit2/Target.pri	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/Target.pri	2013-05-16 00:36:28 UTC (rev 150161)
@@ -915,6 +915,7 @@
 
 enable?(INSPECTOR_SERVER) {
     HEADERS += \
+        UIProcess/InspectorServer/HTTPRequest.h \
         UIProcess/InspectorServer/WebInspectorServer.h \
         UIProcess/InspectorServer/WebSocketServer.h \
         UIProcess/InspectorServer/WebSocketServerClient.h \
@@ -922,6 +923,7 @@
         UIProcess/InspectorServer/qt/WebSocketServerQt.h
 
     SOURCES += \
+        UIProcess/InspectorServer/HTTPRequest.cpp \
         UIProcess/InspectorServer/WebInspectorServer.cpp \
         UIProcess/InspectorServer/WebSocketServer.cpp \
         UIProcess/InspectorServer/WebSocketServerConnection.cpp \

Copied: trunk/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp (from rev 150160, trunk/Source/WebCore/platform/network/HTTPRequest.cpp) (0 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp	2013-05-16 00:36:28 UTC (rev 150161)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2011 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 "HTTPRequest.h"
+
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<HTTPRequest> HTTPRequest::parseHTTPRequestFromBuffer(const char* data, size_t length, String& failureReason)
+{
+    if (!length) {
+        failureReason = "No data to parse.";
+        return 0;
+    }
+
+    // Request we will be building.
+    RefPtr<HTTPRequest> request = HTTPRequest::create();
+
+    // Advance a pointer through the data as needed.
+    const char* pos = data;
+    size_t remainingLength = length;
+
+    // 1. Parse Method + URL.
+    size_t requestLineLength = request->parseRequestLine(pos, remainingLength, failureReason);
+    if (!requestLineLength)
+        return 0;
+    pos += requestLineLength;
+    remainingLength -= requestLineLength;
+
+    // 2. Parse HTTP Headers.
+    size_t headersLength = request->parseHeaders(pos, remainingLength, failureReason);
+    if (!headersLength)
+        return 0;
+    pos += headersLength;
+    remainingLength -= headersLength;
+
+    // 3. Parse HTTP Data.
+    size_t dataLength = request->parseRequestBody(pos, remainingLength);
+    pos += dataLength;
+    remainingLength -= dataLength;
+
+    // We should have processed the entire input.
+    ASSERT(!remainingLength);
+    return request.release();
+}
+
+size_t HTTPRequest::parseRequestLine(const char* data, size_t length, String& failureReason)
+{
+    String url;
+    size_t result = parseHTTPRequestLine(data, length, failureReason, m_requestMethod, url, m_httpVersion);
+    m_url = KURL(KURL(), url);
+    return result;
+}
+
+size_t HTTPRequest::parseHeaders(const char* data, size_t length, String& failureReason)
+{
+    const char* p = data;
+    const char* end = data + length;
+    AtomicString name;
+    String value;
+    for (; p < data + length; p++) {
+        size_t consumedLength = parseHTTPHeader(p, end - p, failureReason, name, value);
+        if (!consumedLength)
+            return 0;
+        p += consumedLength;
+        if (name.isEmpty())
+            break;
+        m_headerFields.add(name, value);
+    }
+    return p - data;
+}
+
+size_t HTTPRequest::parseRequestBody(const char* data, size_t length)
+{
+    return parseHTTPRequestBody(data, length, m_body);
+}
+
+HTTPRequest::HTTPRequest()
+    : m_httpVersion(Unknown)
+{
+}
+
+HTTPRequest::HTTPRequest(const String& requestMethod, const KURL& url, HTTPVersion version)
+    : m_url(url)
+    , m_httpVersion(version)
+    , m_requestMethod(requestMethod)
+{
+}
+
+HTTPRequest::~HTTPRequest()
+{
+}
+
+} // namespace WebCore

Copied: trunk/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h (from rev 150160, trunk/Source/WebCore/platform/network/HTTPRequest.h) (0 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h	2013-05-16 00:36:28 UTC (rev 150161)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Google Inc.  All rights reserved.
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef HTTPRequest_h
+#define HTTPRequest_h
+
+#include <WebCore/HTTPHeaderMap.h>
+#include <WebCore/HTTPParsers.h>
+#include <WebCore/KURL.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class HTTPRequest : public RefCounted<HTTPRequest> {
+public:
+    static PassRefPtr<HTTPRequest> create() { return adoptRef(new HTTPRequest()); }
+    static PassRefPtr<HTTPRequest> create(const String& requestMethod, const WebCore::KURL& url, WebCore::HTTPVersion version) { return adoptRef(new HTTPRequest(requestMethod, url, version)); }
+    static PassRefPtr<HTTPRequest> parseHTTPRequestFromBuffer(const char* data, size_t length, String& failureReason);
+    virtual ~HTTPRequest();
+
+    String requestMethod() const { return m_requestMethod; }
+    void setRequestMethod(const String& method) { m_requestMethod = method; }
+
+    WebCore::KURL url() const { return m_url; }
+    void setURL(const WebCore::KURL& url) { m_url = url; }
+
+    const Vector<unsigned char>& body() const { return m_body; }
+
+    const WebCore::HTTPHeaderMap& headerFields() const { return m_headerFields; }
+    void addHeaderField(const AtomicString& name, const String& value) { m_headerFields.add(name, value); }
+    void addHeaderField(const char* name, const String& value) { m_headerFields.add(name, value); }
+
+protected:
+    HTTPRequest();
+    HTTPRequest(const String& requestMethod, const WebCore::KURL&, WebCore::HTTPVersion);
+
+    // Parsing helpers.
+    size_t parseRequestLine(const char* data, size_t length, String& failureReason);
+    size_t parseHeaders(const char* data, size_t length, String& failureReason);
+    size_t parseRequestBody(const char* data, size_t length);
+
+    WebCore::KURL m_url;
+    WebCore::HTTPVersion m_httpVersion;
+    String m_requestMethod;
+    WebCore::HTTPHeaderMap m_headerFields;
+    Vector<unsigned char> m_body;
+};
+
+} // namespace WebKit
+
+#endif // HTTPRequest_h

Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp (150160 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp	2013-05-16 00:36:28 UTC (rev 150161)
@@ -30,9 +30,9 @@
 
 #include "WebInspectorServer.h"
 
+#include "HTTPRequest.h"
 #include "WebInspectorProxy.h"
 #include "WebSocketServerConnection.h"
-#include <WebCore/HTTPRequest.h>
 
 using namespace WebCore;
 

Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h (150160 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h	2013-05-16 00:36:28 UTC (rev 150161)
@@ -54,9 +54,9 @@
     ~WebInspectorServer();
 
     // WebSocketServerClient implementation. Events coming from remote connections.
-    virtual void didReceiveUnrecognizedHTTPRequest(WebSocketServerConnection*, PassRefPtr<WebCore::HTTPRequest>);
-    virtual bool didReceiveWebSocketUpgradeHTTPRequest(WebSocketServerConnection*, PassRefPtr<WebCore::HTTPRequest>);
-    virtual void didEstablishWebSocketConnection(WebSocketServerConnection*, PassRefPtr<WebCore::HTTPRequest>);
+    virtual void didReceiveUnrecognizedHTTPRequest(WebSocketServerConnection*, PassRefPtr<HTTPRequest>);
+    virtual bool didReceiveWebSocketUpgradeHTTPRequest(WebSocketServerConnection*, PassRefPtr<HTTPRequest>);
+    virtual void didEstablishWebSocketConnection(WebSocketServerConnection*, PassRefPtr<HTTPRequest>);
     virtual void didReceiveWebSocketMessage(WebSocketServerConnection*, const String& message);
     virtual void didCloseWebSocketConnection(WebSocketServerConnection*);
 

Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerClient.h (150160 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerClient.h	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerClient.h	2013-05-16 00:36:28 UTC (rev 150161)
@@ -28,7 +28,7 @@
 
 #if ENABLE(INSPECTOR_SERVER)
 
-#include <WebCore/HTTPRequest.h>
+#include "HTTPRequest.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/text/WTFString.h>
 
@@ -41,13 +41,13 @@
     virtual ~WebSocketServerClient() { }
 
     // Received an HTTP request but didn't know what to do with it.
-    virtual void didReceiveUnrecognizedHTTPRequest(WebSocketServerConnection*, PassRefPtr<WebCore::HTTPRequest>) { }
+    virtual void didReceiveUnrecognizedHTTPRequest(WebSocketServerConnection*, PassRefPtr<HTTPRequest>) { }
 
     // Received a WebSocket Upgrade HTTP request. Ask if we should handle it and upgrade.
-    virtual bool didReceiveWebSocketUpgradeHTTPRequest(WebSocketServerConnection*, PassRefPtr<WebCore::HTTPRequest>) { return true; }
+    virtual bool didReceiveWebSocketUpgradeHTTPRequest(WebSocketServerConnection*, PassRefPtr<HTTPRequest>) { return true; }
 
     // Established a WebSocket Connection.
-    virtual void didEstablishWebSocketConnection(WebSocketServerConnection*, PassRefPtr<WebCore::HTTPRequest>) { }
+    virtual void didEstablishWebSocketConnection(WebSocketServerConnection*, PassRefPtr<HTTPRequest>) { }
 
     // Received a WebSocket message.
     virtual void didReceiveWebSocketMessage(WebSocketServerConnection*, const String&) { }

Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp (150160 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp	2013-05-16 00:36:28 UTC (rev 150161)
@@ -30,9 +30,9 @@
 
 #include "WebSocketServerConnection.h"
 
+#include "HTTPRequest.h"
 #include "WebSocketServer.h"
 #include "WebSocketServerClient.h"
-#include <WebCore/HTTPRequest.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/SocketStreamError.h>
 #include <WebCore/SocketStreamHandle.h>

Modified: trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.h (150160 => 150161)


--- trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.h	2013-05-16 00:29:25 UTC (rev 150160)
+++ trunk/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.h	2013-05-16 00:36:28 UTC (rev 150161)
@@ -37,12 +37,12 @@
 
 namespace WebCore {
 class HTTPHeaderMap;
-class HTTPRequest;
 class SocketStreamHandle;
 }
 
 namespace WebKit {
 
+class HTTPRequest;
 class WebSocketServer;
 class WebSocketServerClient;
 
@@ -76,7 +76,7 @@
     void readHTTPMessage();
 
     // WebSocket Mode.
-    void upgradeToWebSocketServerConnection(PassRefPtr<WebCore::HTTPRequest>);
+    void upgradeToWebSocketServerConnection(PassRefPtr<HTTPRequest>);
     void readWebSocketFrames();
     bool readWebSocketFrame();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to