1 module webkit2webextension.URIResponse;
2 
3 private import glib.Str;
4 private import gobject.ObjectG;
5 private import soup.MessageHeaders;
6 private import webkit2webextension.c.functions;
7 public  import webkit2webextension.c.types;
8 
9 
10 /**
11  * A #WebKitURIResponse contains information such as the URI, the
12  * status code, the content length, the mime type, the HTTP status or
13  * the suggested filename.
14  */
15 public class URIResponse : ObjectG
16 {
17 	/** the main Gtk struct */
18 	protected WebKitURIResponse* webKitURIResponse;
19 
20 	/** Get the main Gtk struct */
21 	public WebKitURIResponse* getURIResponseStruct(bool transferOwnership = false)
22 	{
23 		if (transferOwnership)
24 			ownedRef = false;
25 		return webKitURIResponse;
26 	}
27 
28 	/** the main Gtk struct as a void* */
29 	protected override void* getStruct()
30 	{
31 		return cast(void*)webKitURIResponse;
32 	}
33 
34 	/**
35 	 * Sets our main struct and passes it to the parent class.
36 	 */
37 	public this (WebKitURIResponse* webKitURIResponse, bool ownedRef = false)
38 	{
39 		this.webKitURIResponse = webKitURIResponse;
40 		super(cast(GObject*)webKitURIResponse, ownedRef);
41 	}
42 
43 
44 	/** */
45 	public static GType getType()
46 	{
47 		return webkit_uri_response_get_type();
48 	}
49 
50 	/**
51 	 * Get the expected content length of the #WebKitURIResponse. It can
52 	 * be 0 if the server provided an incorrect or missing Content-Length.
53 	 *
54 	 * Returns: the expected content length of @response.
55 	 */
56 	public ulong getContentLength()
57 	{
58 		return webkit_uri_response_get_content_length(webKitURIResponse);
59 	}
60 
61 	/**
62 	 * Get the HTTP headers of a #WebKitURIResponse as a #SoupMessageHeaders.
63 	 *
64 	 * Returns: a #SoupMessageHeaders with the HTTP headers of @response
65 	 *     or %NULL if @response is not an HTTP response.
66 	 *
67 	 * Since: 2.6
68 	 */
69 	public MessageHeaders getHttpHeaders()
70 	{
71 		auto __p = webkit_uri_response_get_http_headers(webKitURIResponse);
72 
73 		if(__p is null)
74 		{
75 			return null;
76 		}
77 
78 		return ObjectG.getDObject!(MessageHeaders)(cast(SoupMessageHeaders*) __p);
79 	}
80 
81 	/**
82 	 * Returns: the MIME type of the #WebKitURIResponse
83 	 */
84 	public string getMimeType()
85 	{
86 		return Str.toString(webkit_uri_response_get_mime_type(webKitURIResponse));
87 	}
88 
89 	/**
90 	 * Get the status code of the #WebKitURIResponse as returned by
91 	 * the server. It will normally be a #SoupKnownStatusCode, for
92 	 * example %SOUP_STATUS_OK, though the server can respond with any
93 	 * unsigned integer.
94 	 *
95 	 * Returns: the status code of @response
96 	 */
97 	public uint getStatusCode()
98 	{
99 		return webkit_uri_response_get_status_code(webKitURIResponse);
100 	}
101 
102 	/**
103 	 * Get the suggested filename for @response, as specified by
104 	 * the 'Content-Disposition' HTTP header, or %NULL if it's not
105 	 * present.
106 	 *
107 	 * Returns: the suggested filename or %NULL if
108 	 *     the 'Content-Disposition' HTTP header is not present.
109 	 */
110 	public string getSuggestedFilename()
111 	{
112 		return Str.toString(webkit_uri_response_get_suggested_filename(webKitURIResponse));
113 	}
114 
115 	/**
116 	 * Returns: the uri of the #WebKitURIResponse
117 	 */
118 	public string getUri()
119 	{
120 		return Str.toString(webkit_uri_response_get_uri(webKitURIResponse));
121 	}
122 }