/usr/share/gtk-doc/html/libsoup-2.4/libsoup-request-howto.html is in libsoup2.4-doc 2.62.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>libsoup Client SoupRequest API: libsoup Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="libsoup Reference Manual">
<link rel="up" href="ch01.html" title="Tutorial">
<link rel="prev" href="libsoup-client-howto.html" title="libsoup Client Basics">
<link rel="next" href="libsoup-session-porting.html" title="Porting to the new SoupSession">
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="libsoup-client-howto.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="libsoup-session-porting.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="libsoup-request-howto"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">libsoup Client SoupRequest API</span></h2>
<p>libsoup Client SoupRequest API — Using
libsoup with a mix of <code class="literal">http</code> and non-<code class="literal">http</code> URIs.</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect2">
<a name="id-1.2.4.3"></a><h3><span class="type">SoupRequest</span></h3>
<p>
<a class="link" href="SoupRequest.html" title="SoupRequest"><span class="type">SoupRequest</span></a> is an
abstract type representing a request for a particular URI. The
<span class="type">SoupRequest</span> API is an alternative to the <a class="link" href="SoupMessage.html" title="SoupMessage"><span class="type">SoupMessage</span></a>-based <a class="link" href="SoupSession.html" title="SoupSession"><span class="type">SoupSession</span></a> APIs which may be
useful to programs that want to deal with multiple kinds of URIs.
</p>
<p>
<span class="type">SoupRequest</span> officially became part of the
<span class="application">libsoup</span> API in 2.42 with the addition of
<a class="link" href="SoupSession.html#soup-session-request" title="soup_session_request ()"><code class="function">soup_session_request</code></a>
and the related functions. However, parts of it are also available as
far back as <span class="application">libsoup</span> 2.34 via the
(now-deprecated) <span class="type">SoupRequester</span> session feature, if you
define <code class="literal">LIBSOUP_USE_UNSTABLE_REQUEST_API</code> before
including the <span class="application">libsoup</span> headers.
</p>
<p>
Additionally, before <span class="application">libsoup</span> 2.42, the
<span class="type">SoupRequest</span> API was the only way to stream an HTTP
response body via <a href="../gio/GInputStream.html#GInputStream-struct"><span class="type">GInputStream</span></a>. As of 2.42,
there are streaming APIs based on <span class="type">SoupMessage</span> (<a class="link" href="SoupSession.html#soup-session-send" title="soup_session_send ()"><code class="function">soup_session_send</code></a>
and <a class="link" href="SoupSession.html#soup-session-send-async" title="soup_session_send_async ()"><code class="function">soup_session_send_async</code></a>),
so applications that are using <span class="type">SoupRequest</span> with only
<code class="literal">http</code> and <code class="literal">https</code> URIs can be
ported to those APIs now.
</p>
</div>
<hr>
<div class="refsect2">
<a name="id-1.2.4.4"></a><h3>Creating a SoupRequest</h3>
<p>
There are four <span class="type">SoupSession</span> methods for creating
<span class="type">SoupRequest</span>s:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>
<a class="link" href="SoupSession.html#soup-session-request" title="soup_session_request ()"><code class="function">soup_session_request</code></a>
takes an arbitrary URI as a string, and returns a <a class="link" href="SoupRequest.html" title="SoupRequest"><span class="type">SoupRequest</span></a>.
</p></li>
<li class="listitem"><p>
<a class="link" href="SoupSession.html#soup-session-request-uri" title="soup_session_request_uri ()"><code class="function">soup_session_request_uri</code></a>
takes an arbitrary URI as a <a class="link" href="SoupURI.html" title="SoupURI"><span class="type">SoupURI</span></a>,
and returns a <a class="link" href="SoupRequest.html" title="SoupRequest"><span class="type">SoupRequest</span></a>.
</p></li>
<li class="listitem"><p>
<a class="link" href="SoupSession.html#soup-session-request-http" title="soup_session_request_http ()"><code class="function">soup_session_request_http</code></a>
takes an HTTP method and an <code class="literal">http</code> or <code class="literal">https</code> URI as a string, and returns a <a class="link" href="SoupRequestHTTP.html" title="SoupRequestHTTP"><span class="type">SoupRequestHTTP</span></a>.
</p></li>
<li class="listitem"><p>
<a class="link" href="SoupSession.html#soup-session-request-http-uri" title="soup_session_request_http_uri ()"><code class="function">soup_session_request_http_uri</code></a>
takes an HTTP method and an <code class="literal">http</code> or <code class="literal">https</code> URI as a <a class="link" href="SoupURI.html" title="SoupURI"><span class="type">SoupURI</span></a>,
and returns a <a class="link" href="SoupRequestHTTP.html" title="SoupRequestHTTP"><span class="type">SoupRequestHTTP</span></a>.
</p></li>
</ul></div>
</div>
<hr>
<div class="refsect2">
<a name="id-1.2.4.5"></a><h3>Sending a SoupRequest</h3>
<p>
Once you have created a <span class="type">SoupRequest</span>, you can send it with
either <a class="link" href="SoupRequest.html#soup-request-send" title="soup_request_send ()"><code class="function">soup_request_send</code></a>
or <a class="link" href="SoupRequest.html#soup-request-send-async" title="soup_request_send_async ()"><code class="function">soup_request_send_async</code></a>.
This will provide you with a <a href="../gio/GInputStream.html#GInputStream-struct"><span class="type">GInputStream</span></a> which you can
read to get the response body.
</p>
<p>
After sending, you can use <a class="link" href="SoupRequest.html#soup-request-get-content-length" title="soup_request_get_content_length ()"><code class="function">soup_request_get_content_length</code></a>
and <a class="link" href="SoupRequest.html#soup-request-get-content-type" title="soup_request_get_content_type ()"><code class="function">soup_request_get_content_type</code></a>
to get information about the response body.
</p>
<p>
As with the streaming <span class="type">SoupMessage</span>-based APIs,
<code class="function">soup_request_send</code> and
<code class="function">soup_request_send_async</code> only return errors if a
transport-level problem occurs (eg, it could not connect to the host,
or the request was cancelled). In the case of an HTTP request, use the
message's <em class="structfield"><code>status_code</code></em> field to determine
whether the request was successful or not at the HTTP level (ie, "<code class="literal">200
OK</code>" vs "<code class="literal">401 Bad Request</code>"). (You can call <a class="link" href="SoupRequestHTTP.html#soup-request-http-get-message" title="soup_request_http_get_message ()"><code class="function">soup_request_http_get_message</code></a>
to get the request's corresponding <a class="link" href="SoupMessage.html" title="SoupMessage"><span class="type">SoupMessage</span></a>, to look at the
status code or other HTTP metadata.)
</p>
</div>
<hr>
<div class="refsect2">
<a name="id-1.2.4.6"></a><h3>Supported URI types, and adding your own</h3>
<p>
Different URI types are implemented by different subclasses of
<span class="type">SoupRequest</span>. <span class="application">libsoup</span> currently
implements three <span class="type">SoupRequest</span> classes:
</p>
<div class="variablelist"><table border="0" class="variablelist">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><a class="link" href="SoupRequestHTTP.html" title="SoupRequestHTTP"><span class="type">SoupRequestHTTP</span></a></span></p></td>
<td><p>
Handles <code class="literal">http</code> and
<code class="literal">https</code> URI.
</p></td>
</tr>
<tr>
<td><p><span class="term"><a class="link" href="SoupRequestData.html" title="SoupRequestData"><span class="type">SoupRequestData</span></a></span></p></td>
<td><p>
Handles <code class="literal">data</code> URIs containing inline data.
</p></td>
</tr>
<tr>
<td><p><span class="term"><a class="link" href="SoupRequestFile.html" title="SoupRequestFile"><span class="type">SoupRequestFile</span></a></span></p></td>
<td><p>
Handles <code class="literal">file</code> and
<a href="../gio/GResource.html#GResource-struct"><code class="literal">resource</code></a> URIs.
If you request a URI corresponding to a directory, this
will generate an HTML listing of the directory.
</p></td>
</tr>
</tbody>
</table></div>
<p>
You can add additional URI types by implementing your own
<span class="type">SoupRequest</span> subclass; set the
<span class="type">SoupRequestClass</span>'s <em class="structfield"><code>schemes</code></em>
field to point to a <code class="literal">NULL</code>-terminated array of scheme
names, implement the various <span class="type">SoupRequest</span> methods, and
then register the type with your <span class="type">SoupSession</span> by calling
<a class="link" href="SoupSession.html#soup-session-add-feature-by-type" title="soup_session_add_feature_by_type ()"><code class="function">soup_session_add_feature_by_type</code></a>
and passing the <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> of
your request class.
</p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.27</div>
</body>
</html>
|