2 * Copyright (C) 2012 Intel Corporation. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "ewk_url_response.h"
29 #include "ewk_url_response_private.h"
30 #include <wtf/text/CString.h>
32 using namespace WebKit;
34 Ewk_Url_Response::Ewk_Url_Response(const WebCore::ResourceResponse& coreResponse)
35 : m_coreResponse(coreResponse)
36 , m_url(AdoptWK, WKURLResponseCopyURL(WebKit::toAPI(coreResponse)))
37 , m_mimeType(AdoptWK, WKURLResponseCopyMIMEType(WebKit::toAPI(coreResponse)))
40 int Ewk_Url_Response::httpStatusCode() const
42 return m_coreResponse.httpStatusCode();
45 const char* Ewk_Url_Response::url() const
50 const char* Ewk_Url_Response::mimeType() const
55 unsigned long Ewk_Url_Response::contentLength() const
57 return m_coreResponse.expectedContentLength();
60 Ewk_Url_Response* ewk_url_response_ref(Ewk_Url_Response* response)
62 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
68 void ewk_url_response_unref(Ewk_Url_Response* response)
70 EINA_SAFETY_ON_NULL_RETURN(response);
75 const char* ewk_url_response_url_get(const Ewk_Url_Response* response)
77 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
79 return response->url();
82 int ewk_url_response_status_code_get(const Ewk_Url_Response* response)
84 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
86 return response->httpStatusCode();
89 const char* ewk_url_response_mime_type_get(const Ewk_Url_Response* response)
91 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
93 return response->mimeType();
96 unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response* response)
98 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
100 return response->contentLength();