2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
32 #include "WebHTTPLoadInfo.h"
34 #include "ResourceLoadInfo.h"
35 #include "ResourceResponse.h"
36 #include "WebHTTPHeaderVisitor.h"
37 #include "WebString.h"
39 using namespace WebCore;
43 void WebHTTPLoadInfo::initialize()
45 m_private = adoptRef(new ResourceLoadInfo());
48 void WebHTTPLoadInfo::reset()
53 void WebHTTPLoadInfo::assign(const WebHTTPLoadInfo& r)
55 m_private = r.m_private;
58 WebHTTPLoadInfo::WebHTTPLoadInfo(WTF::PassRefPtr<WebCore::ResourceLoadInfo> value)
63 WebHTTPLoadInfo::operator WTF::PassRefPtr<WebCore::ResourceLoadInfo>() const
65 return m_private.get();
68 int WebHTTPLoadInfo::httpStatusCode() const
70 ASSERT(!m_private.isNull());
71 return m_private->httpStatusCode;
74 void WebHTTPLoadInfo::setHTTPStatusCode(int statusCode)
76 ASSERT(!m_private.isNull());
77 m_private->httpStatusCode = statusCode;
80 WebString WebHTTPLoadInfo::httpStatusText() const
82 ASSERT(!m_private.isNull());
83 return m_private->httpStatusText;
86 void WebHTTPLoadInfo::setHTTPStatusText(const WebString& statusText)
88 ASSERT(!m_private.isNull());
89 m_private->httpStatusText = statusText;
92 long long WebHTTPLoadInfo::encodedDataLength() const
94 ASSERT(!m_private.isNull());
95 return m_private->encodedDataLength;
98 void WebHTTPLoadInfo::setEncodedDataLength(long long encodedDataLength)
100 ASSERT(!m_private.isNull());
101 m_private->encodedDataLength = encodedDataLength;
104 static void addHeader(HTTPHeaderMap* map, const WebString& name, const WebString& value)
106 pair<HTTPHeaderMap::iterator, bool> result = map->add(name, value);
108 result.first->second += ", " + String(value);
111 void WebHTTPLoadInfo::addRequestHeader(const WebString& name, const WebString& value)
113 ASSERT(!m_private.isNull());
114 addHeader(&m_private->requestHeaders, name, value);
117 void WebHTTPLoadInfo::addResponseHeader(const WebString& name, const WebString& value)
119 ASSERT(!m_private.isNull());
120 addHeader(&m_private->responseHeaders, name, value);
123 WebString WebHTTPLoadInfo::requestHeadersText() const
125 ASSERT(!m_private.isNull());
126 return m_private->requestHeadersText;
129 void WebHTTPLoadInfo::setRequestHeadersText(const WebString& headersText)
131 ASSERT(!m_private.isNull());
132 m_private->requestHeadersText = headersText;
135 WebString WebHTTPLoadInfo::responseHeadersText() const
137 ASSERT(!m_private.isNull());
138 return m_private->responseHeadersText;
141 void WebHTTPLoadInfo::setResponseHeadersText(const WebString& headersText)
143 ASSERT(!m_private.isNull());
144 m_private->responseHeadersText = headersText;
147 } // namespace WebKit