1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 /* From ppb_url_response_info.idl modified Mon Nov 14 10:36:01 2011. */ 7 8 #ifndef PPAPI_C_PPB_URL_RESPONSE_INFO_H_ 9 #define PPAPI_C_PPB_URL_RESPONSE_INFO_H_ 10 11 #include "ppapi/c/pp_bool.h" 12 #include "ppapi/c/pp_macros.h" 13 #include "ppapi/c/pp_resource.h" 14 #include "ppapi/c/pp_stdint.h" 15 #include "ppapi/c/pp_var.h" 16 17 #define PPB_URLRESPONSEINFO_INTERFACE_1_0 "PPB_URLResponseInfo;1.0" 18 #define PPB_URLRESPONSEINFO_INTERFACE PPB_URLRESPONSEINFO_INTERFACE_1_0 19 20 /** 21 * @file 22 * This file defines the <code>PPB_URLResponseInfo</code> API for examining URL 23 * responses. 24 */ 25 26 27 /** 28 * @addtogroup Enums 29 * @{ 30 */ 31 /** 32 * This enumeration contains properties set on a URL response. 33 */ 34 typedef enum { 35 /** 36 * This corresponds to a string (PP_VARTYPE_STRING); an absolute URL formed by 37 * resolving the relative request URL with the absolute document URL. Refer 38 * to the 39 * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2"> 40 * HTTP Request URI</a> and 41 * <a href="http://www.w3.org/TR/html4/struct/links.html#h-12.4.1"> 42 * HTML Resolving Relative URIs</a> documentation for further information. 43 */ 44 PP_URLRESPONSEPROPERTY_URL = 0, 45 /** 46 * This corresponds to a string (PP_VARTYPE_STRING); the absolute URL returned 47 * in the response header's 'Location' field if this is a redirect response, 48 * an empty string otherwise. Refer to the 49 * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3"> 50 * HTTP Status Codes - Redirection</a> documentation for further information. 51 */ 52 PP_URLRESPONSEPROPERTY_REDIRECTURL = 1, 53 /** 54 * This corresponds to a string (PP_VARTYPE_STRING); the HTTP method to be 55 * used in a new request if this is a redirect response, an empty string 56 * otherwise. Refer to the 57 * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3"> 58 * HTTP Status Codes - Redirection</a> documentation for further information. 59 */ 60 PP_URLRESPONSEPROPERTY_REDIRECTMETHOD = 2, 61 /** 62 * This corresponds to an int32 (PP_VARETYPE_INT32); the status code from the 63 * response, e.g., 200 if the request was successful. Refer to the 64 * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1"> 65 * HTTP Status Code and Reason Phrase</a> documentation for further 66 * information. 67 */ 68 PP_URLRESPONSEPROPERTY_STATUSCODE = 3, 69 /** 70 * This corresponds to a string (PP_VARTYPE_STRING); the status line 71 * from the response. Refer to the 72 * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1"> 73 * HTTP Response Status Line</a> documentation for further information. 74 */ 75 PP_URLRESPONSEPROPERTY_STATUSLINE = 4, 76 /** 77 * This corresponds to a string(PP_VARTYPE_STRING), a \n-delimited list of 78 * header field/value pairs of the form "field: value", returned by the 79 * server. Refer to the 80 * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14"> 81 * HTTP Header Field Definitions</a> documentation for further information. 82 */ 83 PP_URLRESPONSEPROPERTY_HEADERS = 5 84 } PP_URLResponseProperty; 85 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLResponseProperty, 4); 86 /** 87 * @} 88 */ 89 90 /** 91 * @addtogroup Interfaces 92 * @{ 93 */ 94 /** 95 * The PPB_URLResponseInfo interface contains APIs for 96 * examining URL responses. Refer to <code>PPB_URLLoader</code> for further 97 * information. 98 */ 99 struct PPB_URLResponseInfo_1_0 { 100 /** 101 * IsURLResponseInfo() determines if a response is a 102 * <code>URLResponseInfo</code>. 103 * 104 * @param[in] resource A <code>PP_Resource</code> corresponding to a 105 * <code>URLResponseInfo</code>. 106 * 107 * @return <code>PP_TRUE</code> if the resource is a 108 * <code>URLResponseInfo</code>, <code>PP_FALSE</code> if the resource is 109 * invalid or some type other than <code>URLResponseInfo</code>. 110 */ 111 PP_Bool (*IsURLResponseInfo)(PP_Resource resource); 112 /** 113 * GetProperty() gets a response property. 114 * 115 * @param[in] request A <code>PP_Resource</code> corresponding to a 116 * <code>URLResponseInfo</code>. 117 * @param[in] property A <code>PP_URLResponseProperty</code> identifying 118 * the type of property in the response. 119 * 120 * @return A <code>PP_Var</code> containing the response property value if 121 * successful, <code>PP_VARTYPE_VOID</code> if an input parameter is invalid. 122 */ 123 struct PP_Var (*GetProperty)(PP_Resource response, 124 PP_URLResponseProperty property); 125 /** 126 * GetBodyAsFileRef() returns a FileRef pointing to the file containing the 127 * response body. This is only valid if 128 * <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the 129 * <code>URLRequestInfo</code> used to produce this response. This file 130 * remains valid until the <code>URLLoader</code> associated with this 131 * <code>URLResponseInfo</code> is closed or destroyed. 132 * 133 * @param[in] request A <code>PP_Resource</code> corresponding to a 134 * <code>URLResponseInfo</code>. 135 * 136 * @return A <code>PP_Resource</code> corresponding to a <code>FileRef</code> 137 * if successful, 0 if <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was 138 * not requested or if the <code>URLLoader</code> has not been opened yet. 139 */ 140 PP_Resource (*GetBodyAsFileRef)(PP_Resource response); 141 }; 142 143 typedef struct PPB_URLResponseInfo_1_0 PPB_URLResponseInfo; 144 /** 145 * @} 146 */ 147 148 #endif /* PPAPI_C_PPB_URL_RESPONSE_INFO_H_ */ 149 150