| OLD | NEW |
| (Empty) |
| 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 "sky/engine/public/platform/WebHTTPLoadInfo.h" | |
| 32 | |
| 33 #include "sky/engine/platform/network/ResourceLoadInfo.h" | |
| 34 #include "sky/engine/public/platform/WebHTTPHeaderVisitor.h" | |
| 35 #include "sky/engine/public/platform/WebString.h" | |
| 36 | |
| 37 namespace blink { | |
| 38 | |
| 39 void WebHTTPLoadInfo::initialize() | |
| 40 { | |
| 41 m_private = adoptRef(new ResourceLoadInfo()); | |
| 42 } | |
| 43 | |
| 44 void WebHTTPLoadInfo::reset() | |
| 45 { | |
| 46 m_private.reset(); | |
| 47 } | |
| 48 | |
| 49 void WebHTTPLoadInfo::assign(const WebHTTPLoadInfo& r) | |
| 50 { | |
| 51 m_private = r.m_private; | |
| 52 } | |
| 53 | |
| 54 WebHTTPLoadInfo::WebHTTPLoadInfo(WTF::PassRefPtr<ResourceLoadInfo> value) | |
| 55 : m_private(value) | |
| 56 { | |
| 57 } | |
| 58 | |
| 59 WebHTTPLoadInfo::operator WTF::PassRefPtr<ResourceLoadInfo>() const | |
| 60 { | |
| 61 return m_private.get(); | |
| 62 } | |
| 63 | |
| 64 int WebHTTPLoadInfo::httpStatusCode() const | |
| 65 { | |
| 66 ASSERT(!m_private.isNull()); | |
| 67 return m_private->httpStatusCode; | |
| 68 } | |
| 69 | |
| 70 void WebHTTPLoadInfo::setHTTPStatusCode(int statusCode) | |
| 71 { | |
| 72 ASSERT(!m_private.isNull()); | |
| 73 m_private->httpStatusCode = statusCode; | |
| 74 } | |
| 75 | |
| 76 WebString WebHTTPLoadInfo::httpStatusText() const | |
| 77 { | |
| 78 ASSERT(!m_private.isNull()); | |
| 79 return m_private->httpStatusText; | |
| 80 } | |
| 81 | |
| 82 void WebHTTPLoadInfo::setHTTPStatusText(const WebString& statusText) | |
| 83 { | |
| 84 ASSERT(!m_private.isNull()); | |
| 85 m_private->httpStatusText = statusText; | |
| 86 } | |
| 87 | |
| 88 long long WebHTTPLoadInfo::encodedDataLength() const | |
| 89 { | |
| 90 ASSERT(!m_private.isNull()); | |
| 91 return m_private->encodedDataLength; | |
| 92 } | |
| 93 | |
| 94 void WebHTTPLoadInfo::setEncodedDataLength(long long encodedDataLength) | |
| 95 { | |
| 96 ASSERT(!m_private.isNull()); | |
| 97 m_private->encodedDataLength = encodedDataLength; | |
| 98 } | |
| 99 | |
| 100 static void addHeader(HTTPHeaderMap* map, const WebString& name, const WebString
& value) | |
| 101 { | |
| 102 HTTPHeaderMap::AddResult result = map->add(name, value); | |
| 103 // It is important that values are separated by '\n', not comma, otherwise S
et-Cookie header is not parseable. | |
| 104 if (!result.isNewEntry) | |
| 105 result.storedValue->value = result.storedValue->value + "\n" + String(va
lue); | |
| 106 } | |
| 107 | |
| 108 void WebHTTPLoadInfo::addRequestHeader(const WebString& name, const WebString& v
alue) | |
| 109 { | |
| 110 ASSERT(!m_private.isNull()); | |
| 111 addHeader(&m_private->requestHeaders, name, value); | |
| 112 } | |
| 113 | |
| 114 void WebHTTPLoadInfo::addResponseHeader(const WebString& name, const WebString&
value) | |
| 115 { | |
| 116 ASSERT(!m_private.isNull()); | |
| 117 addHeader(&m_private->responseHeaders, name, value); | |
| 118 } | |
| 119 | |
| 120 WebString WebHTTPLoadInfo::requestHeadersText() const | |
| 121 { | |
| 122 ASSERT(!m_private.isNull()); | |
| 123 return m_private->requestHeadersText; | |
| 124 } | |
| 125 | |
| 126 void WebHTTPLoadInfo::setRequestHeadersText(const WebString& headersText) | |
| 127 { | |
| 128 ASSERT(!m_private.isNull()); | |
| 129 m_private->requestHeadersText = headersText; | |
| 130 } | |
| 131 | |
| 132 WebString WebHTTPLoadInfo::responseHeadersText() const | |
| 133 { | |
| 134 ASSERT(!m_private.isNull()); | |
| 135 return m_private->responseHeadersText; | |
| 136 } | |
| 137 | |
| 138 void WebHTTPLoadInfo::setResponseHeadersText(const WebString& headersText) | |
| 139 { | |
| 140 ASSERT(!m_private.isNull()); | |
| 141 m_private->responseHeadersText = headersText; | |
| 142 } | |
| 143 | |
| 144 } // namespace blink | |
| OLD | NEW |