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>
33 * \struct _Ewk_Url_Response
34 * @brief Contains the URL response data.
36 struct _Ewk_Url_Response {
37 unsigned int __ref; /**< the reference count of the object */
38 WebCore::ResourceResponse coreResponse;
43 _Ewk_Url_Response(const WebCore::ResourceResponse& _coreResponse)
45 , coreResponse(_coreResponse)
53 eina_stringshare_del(url);
54 eina_stringshare_del(mimeType);
58 void ewk_url_response_ref(Ewk_Url_Response* response)
60 EINA_SAFETY_ON_NULL_RETURN(response);
64 void ewk_url_response_unref(Ewk_Url_Response* response)
66 EINA_SAFETY_ON_NULL_RETURN(response);
68 if (--response->__ref)
74 const char* ewk_url_response_url_get(const Ewk_Url_Response* response)
76 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
78 Ewk_Url_Response* ewkResponse = const_cast<Ewk_Url_Response*>(response);
79 eina_stringshare_replace(&ewkResponse->url, response->coreResponse.url().string().utf8().data());
84 int ewk_url_response_status_code_get(const Ewk_Url_Response* response)
86 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
88 return response->coreResponse.httpStatusCode();
91 const char* ewk_url_response_mime_type_get(const Ewk_Url_Response* response)
93 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
95 Ewk_Url_Response* ewkResponse = const_cast<Ewk_Url_Response*>(response);
96 eina_stringshare_replace(&ewkResponse->mimeType, response->coreResponse.mimeType().utf8().data());
98 return response->mimeType;
101 unsigned long ewk_url_response_content_length_get(const Ewk_Url_Response* response)
103 EINA_SAFETY_ON_NULL_RETURN_VAL(response, 0);
105 return response->coreResponse.expectedContentLength();
110 * Constructs a Ewk_Url_Response from a WebCore::ResourceResponse.
112 Ewk_Url_Response* ewk_url_response_new(const WebCore::ResourceResponse& coreResponse)
114 return new Ewk_Url_Response(coreResponse);