libxml-nanohttp.html revision d433046ae52b0488a9fad77d2045c0139b8cada8
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>nanohttp</title><meta name="generator" content="DocBook XSL Stylesheets V1.58.1"><style xmlns="http://www.w3.org/TR/xhtml1/transitional" type="text/css"> 3 .synopsis, .classsynopsis { 4 background: #eeeeee; 5 border: solid 1px #aaaaaa; 6 padding: 0.5em; 7 } 8 .programlisting { 9 background: #eeeeff; 10 border: solid 1px #aaaaff; 11 padding: 0.5em; 12 } 13 .variablelist { 14 padding: 4px; 15 margin-left: 3em; 16 } 17 .navigation { 18 background: #ffeeee; 19 border: solid 1px #ffaaaa; 20 margin-top: 0.5em; 21 margin-bottom: 0.5em; 22 } 23 .navigation a { 24 color: #770000; 25 } 26 .navigation a:visited { 27 color: #550000; 28 } 29 .navigation .title { 30 font-size: 200%; 31 } 32 </style><link rel="home" href="index.html" title="Gnome XML Library Reference Manual"><link rel="up" href="libxml-lib.html" title="Libxml Library Reference"><link rel="previous" href="libxml-xinclude.html" title="xinclude"><link rel="next" href="libxml-nanoftp.html" title="nanoftp"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libxml-xinclude.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></img></a></td><td><a accesskey="u" href="libxml-lib.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></img></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></img></a></td><th width="100%" align="center">Gnome XML Library Reference Manual</th><td><a accesskey="n" href="libxml-nanoftp.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></img></a></td></tr></table><div class="refentry" lang="en"><a name="libxml-nanohttp"></a><div class="titlepage"></div><div class="refnamediv"><h2>nanohttp</h2><p>nanohttp — </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis"> 33 34 35 36void <a href="libxml-nanohttp.html#xmlNanoHTTPInit">xmlNanoHTTPInit</a> (void); 37void <a href="libxml-nanohttp.html#xmlNanoHTTPCleanup">xmlNanoHTTPCleanup</a> (void); 38void <a href="libxml-nanohttp.html#xmlNanoHTTPScanProxy">xmlNanoHTTPScanProxy</a> (const char *URL); 39int <a href="libxml-nanohttp.html#xmlNanoHTTPFetch">xmlNanoHTTPFetch</a> (const char *URL, 40 const char *filename, 41 char **contentType); 42void* <a href="libxml-nanohttp.html#xmlNanoHTTPMethod">xmlNanoHTTPMethod</a> (const char *URL, 43 const char *method, 44 const char *input, 45 char **contentType, 46 const char *headers, 47 int ilen); 48void* <a href="libxml-nanohttp.html#xmlNanoHTTPMethodRedir">xmlNanoHTTPMethodRedir</a> (const char *URL, 49 const char *method, 50 const char *input, 51 char **contentType, 52 char **redir, 53 const char *headers, 54 int ilen); 55void* <a href="libxml-nanohttp.html#xmlNanoHTTPOpen">xmlNanoHTTPOpen</a> (const char *URL, 56 char **contentType); 57void* <a href="libxml-nanohttp.html#xmlNanoHTTPOpenRedir">xmlNanoHTTPOpenRedir</a> (const char *URL, 58 char **contentType, 59 char **redir); 60int <a href="libxml-nanohttp.html#xmlNanoHTTPReturnCode">xmlNanoHTTPReturnCode</a> (void *ctx); 61const char* <a href="libxml-nanohttp.html#xmlNanoHTTPAuthHeader">xmlNanoHTTPAuthHeader</a> (void *ctx); 62int <a href="libxml-nanohttp.html#xmlNanoHTTPRead">xmlNanoHTTPRead</a> (void *ctx, 63 void *dest, 64 int len); 65int <a href="libxml-nanohttp.html#xmlNanoHTTPSave">xmlNanoHTTPSave</a> (void *ctxt, 66 const char *filename); 67void <a href="libxml-nanohttp.html#xmlNanoHTTPClose">xmlNanoHTTPClose</a> (void *ctx); 68</pre></div><div class="refsect1" lang="en"><h2>Description</h2><p> 69 70</p></div><div class="refsect1" lang="en"><h2>Details</h2><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPInit"></a>xmlNanoHTTPInit ()</h3><pre class="programlisting">void xmlNanoHTTPInit (void);</pre><p> 71Initialize the HTTP protocol layer. 72Currently it just checks for proxy informations</p><p> 73 74</p></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPCleanup"></a>xmlNanoHTTPCleanup ()</h3><pre class="programlisting">void xmlNanoHTTPCleanup (void);</pre><p> 75Cleanup the HTTP protocol layer.</p><p> 76 77</p></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPScanProxy"></a>xmlNanoHTTPScanProxy ()</h3><pre class="programlisting">void xmlNanoHTTPScanProxy (const char *URL);</pre><p> 78(Re)Initialize the HTTP Proxy context by parsing the URL and finding 79the protocol host port it indicates. 80Should be like http://myproxy/ or http://myproxy:3128/ 81A NULL URL cleans up proxy informations.</p><p> 82 83</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>URL</tt></i>�:</span></td><td> The proxy URL used to initialize the proxy context 84</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPFetch"></a>xmlNanoHTTPFetch ()</h3><pre class="programlisting">int xmlNanoHTTPFetch (const char *URL, 85 const char *filename, 86 char **contentType);</pre><p> 87This function try to fetch the indicated resource via HTTP GET 88and save it's content in the file.</p><p> 89 90</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>URL</tt></i>�:</span></td><td> The URL to load 91</td></tr><tr><td><span class="term"><i><tt>filename</tt></i>�:</span></td><td> the filename where the content should be saved 92</td></tr><tr><td><span class="term"><i><tt>contentType</tt></i>�:</span></td><td> if available the Content-Type information will be 93 returned at that location 94</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>-1 in case of failure, 0 incase of success. The contentType, 95 if provided must be freed by the caller 96</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPMethod"></a>xmlNanoHTTPMethod ()</h3><pre class="programlisting">void* xmlNanoHTTPMethod (const char *URL, 97 const char *method, 98 const char *input, 99 char **contentType, 100 const char *headers, 101 int ilen);</pre><p> 102This function try to open a connection to the indicated resource 103via HTTP using the given <i><tt>method</tt></i>, adding the given extra headers 104and the input buffer for the request content.</p><p> 105 106</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>URL</tt></i>�:</span></td><td> The URL to load 107</td></tr><tr><td><span class="term"><i><tt>method</tt></i>�:</span></td><td> the HTTP method to use 108</td></tr><tr><td><span class="term"><i><tt>input</tt></i>�:</span></td><td> the input string if any 109</td></tr><tr><td><span class="term"><i><tt>contentType</tt></i>�:</span></td><td> the Content-Type information IN and OUT 110</td></tr><tr><td><span class="term"><i><tt>headers</tt></i>�:</span></td><td> the extra headers 111</td></tr><tr><td><span class="term"><i><tt>ilen</tt></i>�:</span></td><td> input length 112</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPMethodRedir"></a>xmlNanoHTTPMethodRedir ()</h3><pre class="programlisting">void* xmlNanoHTTPMethodRedir (const char *URL, 113 const char *method, 114 const char *input, 115 char **contentType, 116 char **redir, 117 const char *headers, 118 int ilen);</pre><p> 119This function try to open a connection to the indicated resource 120via HTTP using the given <i><tt>method</tt></i>, adding the given extra headers 121and the input buffer for the request content.</p><p> 122 123</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>URL</tt></i>�:</span></td><td> The URL to load 124</td></tr><tr><td><span class="term"><i><tt>method</tt></i>�:</span></td><td> the HTTP method to use 125</td></tr><tr><td><span class="term"><i><tt>input</tt></i>�:</span></td><td> the input string if any 126</td></tr><tr><td><span class="term"><i><tt>contentType</tt></i>�:</span></td><td> the Content-Type information IN and OUT 127</td></tr><tr><td><span class="term"><i><tt>redir</tt></i>�:</span></td><td> the redirected URL OUT 128</td></tr><tr><td><span class="term"><i><tt>headers</tt></i>�:</span></td><td> the extra headers 129</td></tr><tr><td><span class="term"><i><tt>ilen</tt></i>�:</span></td><td> input length 130</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPOpen"></a>xmlNanoHTTPOpen ()</h3><pre class="programlisting">void* xmlNanoHTTPOpen (const char *URL, 131 char **contentType);</pre><p> 132This function try to open a connection to the indicated resource 133via HTTP GET.</p><p> 134 135</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>URL</tt></i>�:</span></td><td> The URL to load 136</td></tr><tr><td><span class="term"><i><tt>contentType</tt></i>�:</span></td><td> if available the Content-Type information will be 137 returned at that location 138</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPOpenRedir"></a>xmlNanoHTTPOpenRedir ()</h3><pre class="programlisting">void* xmlNanoHTTPOpenRedir (const char *URL, 139 char **contentType, 140 char **redir);</pre><p> 141This function try to open a connection to the indicated resource 142via HTTP GET.</p><p> 143 144</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>URL</tt></i>�:</span></td><td> The URL to load 145</td></tr><tr><td><span class="term"><i><tt>contentType</tt></i>�:</span></td><td> if available the Content-Type information will be 146 returned at that location 147</td></tr><tr><td><span class="term"><i><tt>redir</tt></i>�:</span></td><td> if available the redirected URL will be returned 148</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPReturnCode"></a>xmlNanoHTTPReturnCode ()</h3><pre class="programlisting">int xmlNanoHTTPReturnCode (void *ctx);</pre><p> 149Get the latest HTTP return code received</p><p> 150 151</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>�:</span></td><td> the HTTP context 152</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the HTTP return code for the request. 153</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPAuthHeader"></a>xmlNanoHTTPAuthHeader ()</h3><pre class="programlisting">const char* xmlNanoHTTPAuthHeader (void *ctx);</pre><p> 154Get the authentication header of an HTTP context</p><p> 155 156</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>�:</span></td><td> the HTTP context 157</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the stashed value of the WWW-Authenticate or Proxy-Authenticate 158header. 159</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPRead"></a>xmlNanoHTTPRead ()</h3><pre class="programlisting">int xmlNanoHTTPRead (void *ctx, 160 void *dest, 161 int len);</pre><p> 162This function tries to read <i><tt>len</tt></i> bytes from the existing HTTP connection 163and saves them in <i><tt>dest</tt></i>. This is a blocking call.</p><p> 164 165</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>�:</span></td><td> the HTTP context 166</td></tr><tr><td><span class="term"><i><tt>dest</tt></i>�:</span></td><td> a buffer 167</td></tr><tr><td><span class="term"><i><tt>len</tt></i>�:</span></td><td> the buffer length 168</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the number of byte read. 0 is an indication of an end of connection. 169 -1 indicates a parameter error. 170</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPSave"></a>xmlNanoHTTPSave ()</h3><pre class="programlisting">int xmlNanoHTTPSave (void *ctxt, 171 const char *filename);</pre><p> 172This function saves the output of the HTTP transaction to a file 173It closes and free the context at the end</p><p> 174 175</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>�:</span></td><td> the HTTP context 176</td></tr><tr><td><span class="term"><i><tt>filename</tt></i>�:</span></td><td> the filename where the content should be saved 177</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>-1 in case of failure, 0 incase of success. 178</td></tr></tbody></table></div></div><hr xmlns="http://www.w3.org/TR/xhtml1/transitional"></hr><div class="refsect2" lang="en"><h3><a name="xmlNanoHTTPClose"></a>xmlNanoHTTPClose ()</h3><pre class="programlisting">void xmlNanoHTTPClose (void *ctx);</pre><p> 179This function closes an HTTP context, it ends up the connection and 180free all data related to it.</p><p> 181 182</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i><tt>ctx</tt></i>�:</span></td><td> the HTTP context 183</td></tr></tbody></table></div></div></div></div><table xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="libxml-xinclude.html"><b><<�xinclude</b></a></td><td align="right"><a accesskey="n" href="libxml-nanoftp.html"><b>nanoftp�>></b></a></td></tr></table></body></html> 184