1 /*
2  * Copyright (C) 2010 Google Inc.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "config.h"
32 
33 #if ENABLE(WEB_SOCKETS)
34 
35 #include "WebSocketHandshakeRequest.h"
36 
37 #include <cstring>
38 
39 using namespace std;
40 
41 namespace WebCore {
42 
Key3()43 WebSocketHandshakeRequest::Key3::Key3()
44 {
45     memset(value, 0, sizeof(value));
46 }
47 
set(const unsigned char key3[8])48 void WebSocketHandshakeRequest::Key3::set(const unsigned char key3[8])
49 {
50     memcpy(value, key3, sizeof(value));
51 }
52 
WebSocketHandshakeRequest(const String & requestMethod,const KURL & url)53 WebSocketHandshakeRequest::WebSocketHandshakeRequest(const String& requestMethod, const KURL& url)
54     : m_url(url)
55     , m_requestMethod(requestMethod)
56 {
57 }
58 
~WebSocketHandshakeRequest()59 WebSocketHandshakeRequest::~WebSocketHandshakeRequest()
60 {
61 }
62 
requestMethod() const63 String WebSocketHandshakeRequest::requestMethod() const
64 {
65     return m_requestMethod;
66 }
67 
url() const68 KURL WebSocketHandshakeRequest::url() const
69 {
70     return m_url;
71 }
72 
addHeaderField(const char * name,const String & value)73 void WebSocketHandshakeRequest::addHeaderField(const char* name, const String& value)
74 {
75     m_headerFields.add(name, value);
76 }
77 
headerFields() const78 const HTTPHeaderMap& WebSocketHandshakeRequest::headerFields() const
79 {
80     return m_headerFields;
81 }
82 
key3() const83 WebSocketHandshakeRequest::Key3 WebSocketHandshakeRequest::key3() const
84 {
85     return m_key3;
86 }
87 
setKey3(const unsigned char key3[8])88 void WebSocketHandshakeRequest::setKey3(const unsigned char key3[8])
89 {
90     m_key3.set(key3);
91 }
92 
93 } // namespace WebCore
94 
95 #endif // ENABLE(WEB_SOCKETS)
96