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