Sophie

Sophie

distrib > Mandriva > 2010.2 > i586 > media > contrib-backports > by-pkgid > f00c83953c7eb23ee3c18f4f35d8eb6b > files > 183

sfml2-doc-2.0-0.1mdv2010.2.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>SFML - Simple and Fast Multimedia Library</title>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="tabs.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="logo">
            <img src="./logo.jpg" width="770" height="200" title="SFML home" alt="SFML logo" />
        </div>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.htm"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.htm"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.htm"><span>Classes</span></a></li>
      <li><a href="files.htm"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.htm"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.htm"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.htm"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.htm"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><b>sf</b>::<a class="el" href="classsf_1_1Http.htm">Http</a>
  </div>
</div>
<div class="contents">
<h1>sf::Http Class Reference<br/>
<small>
[<a class="el" href="group__network.htm">Network module</a>]</small>
</h1><!-- doxytag: class="sf::Http" --><!-- doxytag: inherits="sf::NonCopyable" -->
<p>A HTTP client.  
<a href="#_details">More...</a></p>

<p><code>#include &lt;<a class="el" href="Http_8hpp_source.htm">Http.hpp</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for sf::Http:</div>
<div class="dynsection">
 <div class="center">
  <img src="classsf_1_1Http.png" usemap="#sf::Http_map" alt=""/>
  <map id="sf::Http_map" name="sf::Http_map">
<area href="classsf_1_1NonCopyable.htm" alt="sf::NonCopyable" shape="rect" coords="0,0,105,24"/>
</map>
 </div>
</div>

<p><a href="classsf_1_1Http-members.htm">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Http_1_1Request.htm">Request</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Define a HTTP request.  <a href="classsf_1_1Http_1_1Request.htm#_details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">class &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Http_1_1Response.htm">Response</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Define a HTTP response.  <a href="classsf_1_1Http_1_1Response.htm#_details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Http.htm#abe2360194f99bdde402c9f97a85cf067">Http</a> ()</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Default constructor.  <a href="#abe2360194f99bdde402c9f97a85cf067"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Http.htm#a79efd844a735f083fcce0edbf1092385">Http</a> (const std::string &amp;host, unsigned short port=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Construct the HTTP client with the target host.  <a href="#a79efd844a735f083fcce0edbf1092385"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Http.htm#a5e5389e065c56301e9554967291db8c6">SetHost</a> (const std::string &amp;host, unsigned short port=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the target host.  <a href="#a5e5389e065c56301e9554967291db8c6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classsf_1_1Http_1_1Response.htm">Response</a>&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsf_1_1Http.htm#aa13518b0aa16b34abb19c5ef198a789f">SendRequest</a> (const <a class="el" href="classsf_1_1Http_1_1Request.htm">Request</a> &amp;request, Uint32 timeout=0)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Send a HTTP request and return the server's response.  <a href="#aa13518b0aa16b34abb19c5ef198a789f"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>A HTTP client. </p>
<p><a class="el" href="classsf_1_1Http.htm" title="A HTTP client.">sf::Http</a> is a very simple HTTP client that allows you to communicate with a web server.</p>
<p>You can retrieve web pages, send data to an interactive resource, download a remote file, etc.</p>
<p>The HTTP client is split into 3 classes: </p>
<ul>
<li><a class="el" href="classsf_1_1Http_1_1Request.htm" title="Define a HTTP request.">sf::Http::Request</a> </li>
<li><a class="el" href="classsf_1_1Http_1_1Response.htm" title="Define a HTTP response.">sf::Http::Response</a> </li>
<li><a class="el" href="classsf_1_1Http.htm" title="A HTTP client.">sf::Http</a></li>
</ul>
<p><a class="el" href="classsf_1_1Http_1_1Request.htm" title="Define a HTTP request.">sf::Http::Request</a> builds the request that will be sent to the server. A request is made of: </p>
<ul>
<li>a method (what you want to do) </li>
<li>a target URI (usually the name of the web page or file) </li>
<li>one or more header fields (options that you can pass to the server) </li>
<li>an optional body (for POST requests)</li>
</ul>
<p><a class="el" href="classsf_1_1Http_1_1Response.htm" title="Define a HTTP response.">sf::Http::Response</a> parse the response from the web server and provides getters to read them. The response contains: </p>
<ul>
<li>a status code </li>
<li>header fields (that may be answers to the ones that you requested) </li>
<li>a body, which contains the contents of the requested resource</li>
</ul>
<p><a class="el" href="classsf_1_1Http.htm" title="A HTTP client.">sf::Http</a> provides a simple function, SendRequest, to send a <a class="el" href="classsf_1_1Http_1_1Request.htm" title="Define a HTTP request.">sf::Http::Request</a> and return the corresponding <a class="el" href="classsf_1_1Http_1_1Response.htm" title="Define a HTTP response.">sf::Http::Response</a> from the server.</p>
<p>Usage example: </p>
<div class="fragment"><pre class="fragment"> <span class="comment">// Create a new HTTP client</span>
 <a class="code" href="classsf_1_1Http.htm" title="A HTTP client.">sf::Http</a> http;

 <span class="comment">// We&#39;ll work on http://www.sfml-dev.org</span>
 http.<a class="code" href="classsf_1_1Http.htm#a5e5389e065c56301e9554967291db8c6" title="Set the target host.">SetHost</a>(<span class="stringliteral">&quot;http://www.sfml-dev.org&quot;</span>);

 <span class="comment">// Prepare a request to get the &#39;features.php&#39; page</span>
 <a class="code" href="classsf_1_1Http_1_1Request.htm" title="Define a HTTP request.">sf::Http::Request</a> request(<span class="stringliteral">&quot;features.php&quot;</span>);

 <span class="comment">// Send the request</span>
 <a class="code" href="classsf_1_1Http_1_1Response.htm" title="Define a HTTP response.">sf::Http::Response</a> response = http.<a class="code" href="classsf_1_1Http.htm#aa13518b0aa16b34abb19c5ef198a789f" title="Send a HTTP request and return the server&amp;#39;s response.">SendRequest</a>(request);

 <span class="comment">// Check the status code and display the result</span>
 <a class="code" href="classsf_1_1Http_1_1Response.htm#a663e071978e30fbbeb20ed045be874d8" title="Enumerate all the valid status codes for a response.">sf::Http::Response::Status</a> status = response.<a class="code" href="classsf_1_1Http_1_1Response.htm#a1b512118bffb4052af0fa19d858d8121" title="Get the response status code.">GetStatus</a>();
 <span class="keywordflow">if</span> (status == <a class="code" href="classsf_1_1Http_1_1Response.htm#a663e071978e30fbbeb20ed045be874d8a0158f932254d3f09647dd1f64bd43832" title="Most common code returned when operation was successful.">sf::Http::Response::Ok</a>)
 {
     std::cout &lt;&lt; response.<a class="code" href="classsf_1_1Http_1_1Response.htm#a608d79870287073ea7b3b0f4e59acd22" title="Get the body of the response.">GetBody</a>() &lt;&lt; std::endl;
 }
 <span class="keywordflow">else</span>
 {
     std::cout &lt;&lt; <span class="stringliteral">&quot;Error &quot;</span> &lt;&lt; status &lt;&lt; std::endl;
 }
</pre></div> 
<p>Definition at line <a class="el" href="Http_8hpp_source.htm#l00044">44</a> of file <a class="el" href="Http_8hpp_source.htm">Http.hpp</a>.</p>
<hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="abe2360194f99bdde402c9f97a85cf067"></a><!-- doxytag: member="sf::Http::Http" ref="abe2360194f99bdde402c9f97a85cf067" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sf::Http::Http </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Default constructor. </p>

</div>
</div>
<a class="anchor" id="a79efd844a735f083fcce0edbf1092385"></a><!-- doxytag: member="sf::Http::Http" ref="a79efd844a735f083fcce0edbf1092385" args="(const std::string &amp;host, unsigned short port=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">sf::Http::Http </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&nbsp;</td>
          <td class="paramname"> <em>host</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned short&nbsp;</td>
          <td class="paramname"> <em>port</em> = <code>0</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Construct the HTTP client with the target host. </p>
<p>This is equivalent to calling SetHost(host, port). The port has a default value of 0, which means that the HTTP client will use the right port according to the protocol used (80 for HTTP, 443 for HTTPS). You should leave it like this unless you really need a port other than the standard one, or use an unknown protocol.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>host</em>&nbsp;</td><td>Web server to connect to </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>port</em>&nbsp;</td><td>Port to use for connection </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="aa13518b0aa16b34abb19c5ef198a789f"></a><!-- doxytag: member="sf::Http::SendRequest" ref="aa13518b0aa16b34abb19c5ef198a789f" args="(const Request &amp;request, Uint32 timeout=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classsf_1_1Http_1_1Response.htm">Response</a> sf::Http::SendRequest </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classsf_1_1Http_1_1Request.htm">Request</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>request</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Uint32&nbsp;</td>
          <td class="paramname"> <em>timeout</em> = <code>0</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Send a HTTP request and return the server's response. </p>
<p>You must have a valid host before sending a request (see SetHost). Any missing mandatory header field in the request will be added with an appropriate value. Warning: this function waits for the server's response and may not return instantly; use a thread if you don't want to block your application, or use a timeout to limit the time to wait. A value of 0 means that the client will use the system defaut timeout (which is usually pretty long).</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>request</em>&nbsp;</td><td><a class="el" href="classsf_1_1Http_1_1Request.htm" title="Define a HTTP request.">Request</a> to send </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>timeout</em>&nbsp;</td><td>Maximum time to wait, in milliseconds</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Server's response </dd></dl>

</div>
</div>
<a class="anchor" id="a5e5389e065c56301e9554967291db8c6"></a><!-- doxytag: member="sf::Http::SetHost" ref="a5e5389e065c56301e9554967291db8c6" args="(const std::string &amp;host, unsigned short port=0)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sf::Http::SetHost </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&nbsp;</td>
          <td class="paramname"> <em>host</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned short&nbsp;</td>
          <td class="paramname"> <em>port</em> = <code>0</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Set the target host. </p>
<p>This function just stores the host address and port, it doesn't actually connect to it until you send a request. The port has a default value of 0, which means that the HTTP client will use the right port according to the protocol used (80 for HTTP, 443 for HTTPS). You should leave it like this unless you really need a port other than the standard one, or use an unknown protocol.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>host</em>&nbsp;</td><td>Web server to connect to </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>port</em>&nbsp;</td><td>Port to use for connection </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="Http_8hpp_source.htm">Http.hpp</a></li>
</ul>
</div>

        <p id="footer">
            &nbsp;::&nbsp; Copyright &copy; 2007-2008 Laurent Gomila, all rights reserved &nbsp;::&nbsp;
            Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.5.2</a> &nbsp;::&nbsp;
        </p>

    </body>
</html>