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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::Net::HTTPClientSession</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.Net.html" class="namespace">Poco::Net</a></h1>
<h1 class="symbol">class HTTPClientSession</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Net<br />
<b>Package:</b> HTTPClient<br />
<b>Header:</b> Poco/Net/HTTPClientSession.h</p>
<h2>Description</h2>
<div class="description">
<p>This class implements the client-side of a HTTP session. </p>
<p>To send a HTTP request to a HTTP server, first instantiate a <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a> object and specify the server's host name and port number. </p>
<p>Then create a <a href="Poco.Net.HTTPRequest.html" title="class Poco::Net::HTTPRequest">HTTPRequest</a> object, fill it accordingly, and pass it as argument to the sendRequst() method. </p>
<p><a href="Poco.Net.HTTPClientSession.html#12577" title="Poco::Net::HTTPClientSession::sendRequest()">sendRequest</a>() will return an output stream that can be used to send the request body, if there is any. </p>
<p>After you are done sending the request body, create a <a href="Poco.Net.HTTPResponse.html" title="class Poco::Net::HTTPResponse">HTTPResponse</a> object and pass it to <a href="Poco.Net.HTTPClientSession.html#12579" title="Poco::Net::HTTPClientSession::receiveResponse()">receiveResponse</a>(). </p>
<p>This will return an input stream that can be used to read the response body. </p>
<p>See <a href="http://www.ietf.org/rfc/rfc2616.txt" target="_blank">RFC 2616</a> <<a href="http://www.faqs.org/rfcs/rfc2616.html" target="_blank">http://www.faqs.org/rfcs/rfc2616.html</a>> for more information about the HTTP protocol. </p>
</div>
<h2>Inheritance</h2>
<p><b>Direct Base Classes: </b><a href="Poco.Net.HTTPSession.html" title="class Poco::Net::HTTPSession">HTTPSession</a></p>
<p><b>All Base Classes: </b><a href="Poco.Net.HTTPSession.html" title="class Poco::Net::HTTPSession">HTTPSession</a></p>
<p><b>Known Derived Classes: </b><a href="Poco.Net.HTTPSClientSession.html" title="class Poco::Net::HTTPSClientSession">HTTPSClientSession</a></p>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.Net.HTTPClientSession.html#12589" title="Poco::Net::HTTPClientSession::deleteRequestStream()">deleteRequestStream</a>, <a href="Poco.Net.HTTPClientSession.html#12588" title="Poco::Net::HTTPClientSession::deleteResponseStream()">deleteResponseStream</a>, <a href="Poco.Net.HTTPClientSession.html#12600" title="Poco::Net::HTTPClientSession::getExpectResponseBody()">getExpectResponseBody</a>, <a href="Poco.Net.HTTPClientSession.html#12561" title="Poco::Net::HTTPClientSession::getHost()">getHost</a>, <a href="Poco.Net.HTTPClientSession.html#12576" title="Poco::Net::HTTPClientSession::getKeepAliveTimeout()">getKeepAliveTimeout</a>, <a href="Poco.Net.HTTPClientSession.html#12564" title="Poco::Net::HTTPClientSession::getPort()">getPort</a>, <a href="Poco.Net.HTTPClientSession.html#12572" title="Poco::Net::HTTPClientSession::getProxyHost()">getProxyHost</a>, <a href="Poco.Net.HTTPClientSession.html#12573" title="Poco::Net::HTTPClientSession::getProxyPort()">getProxyPort</a>, <a href="Poco.Net.HTTPClientSession.html#12595" title="Poco::Net::HTTPClientSession::getRequestStream()">getRequestStream</a>, <a href="Poco.Net.HTTPClientSession.html#12594" title="Poco::Net::HTTPClientSession::getResponseStream()">getResponseStream</a>, <a href="Poco.Net.HTTPClientSession.html#12601" title="Poco::Net::HTTPClientSession::mustReconnect()">mustReconnect</a>, <a href="Poco.Net.HTTPClientSession.html#12587" title="Poco::Net::HTTPClientSession::proxyRequestPrefix()">proxyRequestPrefix</a>, <a href="Poco.Net.HTTPClientSession.html#12579" title="Poco::Net::HTTPClientSession::receiveResponse()">receiveResponse</a>, <a href="Poco.Net.HTTPClientSession.html#12583" title="Poco::Net::HTTPClientSession::reconnect()">reconnect</a>, <a href="Poco.Net.HTTPClientSession.html#12577" title="Poco::Net::HTTPClientSession::sendRequest()">sendRequest</a>, <a href="Poco.Net.HTTPClientSession.html#12598" title="Poco::Net::HTTPClientSession::setExpectResponseBody()">setExpectResponseBody</a>, <a href="Poco.Net.HTTPClientSession.html#12559" title="Poco::Net::HTTPClientSession::setHost()">setHost</a>, <a href="Poco.Net.HTTPClientSession.html#12574" title="Poco::Net::HTTPClientSession::setKeepAliveTimeout()">setKeepAliveTimeout</a>, <a href="Poco.Net.HTTPClientSession.html#12562" title="Poco::Net::HTTPClientSession::setPort()">setPort</a>, <a href="Poco.Net.HTTPClientSession.html#12565" title="Poco::Net::HTTPClientSession::setProxy()">setProxy</a>, <a href="Poco.Net.HTTPClientSession.html#12568" title="Poco::Net::HTTPClientSession::setProxyHost()">setProxyHost</a>, <a href="Poco.Net.HTTPClientSession.html#12570" title="Poco::Net::HTTPClientSession::setProxyPort()">setProxyPort</a>, <a href="Poco.Net.HTTPClientSession.html#12596" title="Poco::Net::HTTPClientSession::setReconnect()">setReconnect</a>, <a href="Poco.Net.HTTPClientSession.html#12592" title="Poco::Net::HTTPClientSession::setRequestStream()">setRequestStream</a>, <a href="Poco.Net.HTTPClientSession.html#12590" title="Poco::Net::HTTPClientSession::setResponseStream()">setResponseStream</a>, <a href="Poco.Net.HTTPClientSession.html#12584" title="Poco::Net::HTTPClientSession::write()">write</a></p>
<p><b>Inherited Functions: </b><a href="Poco.Net.HTTPSession.html#13169" title="Poco::Net::HTTPSession::abort()">abort</a>, <a href="Poco.Net.HTTPSession.html#13197" title="Poco::Net::HTTPSession::attachSocket()">attachSocket</a>, <a href="Poco.Net.HTTPSession.html#13192" title="Poco::Net::HTTPSession::buffered()">buffered</a>, <a href="Poco.Net.HTTPSession.html#13199" title="Poco::Net::HTTPSession::close()">close</a>, <a href="Poco.Net.HTTPSession.html#13195" title="Poco::Net::HTTPSession::connect()">connect</a>, <a href="Poco.Net.HTTPSession.html#13168" title="Poco::Net::HTTPSession::connected()">connected</a>, <a href="Poco.Net.HTTPSession.html#13173" title="Poco::Net::HTTPSession::detachSocket()">detachSocket</a>, <a href="Poco.Net.HTTPSession.html#13181" title="Poco::Net::HTTPSession::get()">get</a>, <a href="Poco.Net.HTTPSession.html#13164" title="Poco::Net::HTTPSession::getKeepAlive()">getKeepAlive</a>, <a href="Poco.Net.HTTPSession.html#13167" title="Poco::Net::HTTPSession::getTimeout()">getTimeout</a>, <a href="Poco.Net.HTTPSession.html#13170" title="Poco::Net::HTTPSession::networkException()">networkException</a>, <a href="Poco.Net.HTTPSession.html#13182" title="Poco::Net::HTTPSession::peek()">peek</a>, <a href="Poco.Net.HTTPSession.html#13183" title="Poco::Net::HTTPSession::read()">read</a>, <a href="Poco.Net.HTTPSession.html#13189" title="Poco::Net::HTTPSession::receive()">receive</a>, <a href="Poco.Net.HTTPSession.html#13194" title="Poco::Net::HTTPSession::refill()">refill</a>, <a href="Poco.Net.HTTPSession.html#13200" title="Poco::Net::HTTPSession::setException()">setException</a>, <a href="Poco.Net.HTTPSession.html#13162" title="Poco::Net::HTTPSession::setKeepAlive()">setKeepAlive</a>, <a href="Poco.Net.HTTPSession.html#13165" title="Poco::Net::HTTPSession::setTimeout()">setTimeout</a>, <a href="Poco.Net.HTTPSession.html#13193" title="Poco::Net::HTTPSession::socket()">socket</a>, <a href="Poco.Net.HTTPSession.html#13186" title="Poco::Net::HTTPSession::write()">write</a></p>
<h2>Enumerations</h2>
<h3><i>Anonymous</i> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<div class="description">
<p></p>
</div>
<p class="decl"><a name="12582">DEFAULT_KEEP_ALIVE_TIMEOUT</a> = 8</p>
<div class="description">
<p></p>
</div>
<h2>Constructors</h2>
<h3><a name="12550">HTTPClientSession</a></h3>
<p class="decl"><a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a>();</p>
<div class="description">
<p>Creates an unconnected <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a>. </p>
</div>
<h3><a name="12551">HTTPClientSession</a></h3>
<p class="decl">explicit <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a>(<br /> const <a href="Poco.Net.StreamSocket.html" title="class Poco::Net::StreamSocket">StreamSocket</a> & socket<br />);</p>
<div class="description">
<p>Creates a <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a> using the given socket. The socket must not be connected. The session takes ownership of the socket. </p>
</div>
<h3><a name="12553">HTTPClientSession</a></h3>
<p class="decl">explicit <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a>(<br /> const <a href="Poco.Net.SocketAddress.html" title="class Poco::Net::SocketAddress">SocketAddress</a> & address<br />);</p>
<div class="description">
<p>Creates a <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a> using the given address. </p>
</div>
<h3><a name="12555">HTTPClientSession</a></h3>
<p class="decl"><a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a>(<br /> const std::string & host,<br /> <a href="Poco.html#11352" title="Poco::UInt16">Poco::UInt16</a> port = HTTPSession::HTTP_PORT<br />);</p>
<div class="description">
<p>Creates a <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a> using the given host and port. </p>
</div>
<h2>Destructor</h2>
<h3><a name="12558">~HTTPClientSession</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual ~<a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a>();</p>
<div class="description">
<p>Destroys the <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a> and closes the underlying socket. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="12561">getHost</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">const std::string & getHost() const;</p>
<div class="description">
<p>Returns the host name of the target HTTP server. </p>
</div>
<h3><a name="12576">getKeepAliveTimeout</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">const <a href="Poco.Timespan.html" title="class Poco::Timespan">Poco::Timespan</a> & getKeepAliveTimeout() const;</p>
<div class="description">
<p>Returns the connection timeout for HTTP connections. </p>
</div>
<h3><a name="12564">getPort</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.html#11352" title="Poco::UInt16">Poco::UInt16</a> getPort() const;</p>
<div class="description">
<p>Returns the port number of the target HTTP server. </p>
</div>
<h3><a name="12572">getProxyHost</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">const std::string & getProxyHost() const;</p>
<div class="description">
<p>Returns the proxy host name. </p>
</div>
<h3><a name="12573">getProxyPort</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.html#11352" title="Poco::UInt16">Poco::UInt16</a> getProxyPort() const;</p>
<div class="description">
<p>Returns the proxy port number. </p>
</div>
<h3><a name="12579">receiveResponse</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual std::istream & receiveResponse(<br /> <a href="Poco.Net.HTTPResponse.html" title="class Poco::Net::HTTPResponse">HTTPResponse</a> & response<br />);</p>
<div class="description">
<p>Receives the header for the response to the previous HTTP request. </p>
<p>The returned input stream can be used to read the response body. The stream is valid until <a href="Poco.Net.HTTPClientSession.html#12577" title="Poco::Net::HTTPClientSession::sendRequest()">sendRequest</a>() is called or the session is destroyed. </p>
</div>
<h3><a name="12577">sendRequest</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual std::ostream & sendRequest(<br /> <a href="Poco.Net.HTTPRequest.html" title="class Poco::Net::HTTPRequest">HTTPRequest</a> & request<br />);</p>
<div class="description">
<p>Sends the header for the given HTTP request to the server. </p>
<p>The <a href="Poco.Net.HTTPClientSession.html" title="class Poco::Net::HTTPClientSession">HTTPClientSession</a> will set the request's Host and Keep-Alive headers accordingly. </p>
<p>The returned output stream can be used to write the request body. The stream is valid until <a href="Poco.Net.HTTPClientSession.html#12579" title="Poco::Net::HTTPClientSession::receiveResponse()">receiveResponse</a>() is called or the session is destroyed. </p>
</div>
<h3><a name="12559">setHost</a></h3>
<p class="decl">void setHost(<br /> const std::string & host<br />);</p>
<div class="description">
<p>Sets the host name of the target HTTP server. </p>
<p>The host must not be changed once there is an open connection to the server. </p>
</div>
<h3><a name="12574">setKeepAliveTimeout</a></h3>
<p class="decl">void setKeepAliveTimeout(<br /> const <a href="Poco.Timespan.html" title="class Poco::Timespan">Poco::Timespan</a> & timeout<br />);</p>
<div class="description">
<p>Sets the connection timeout for HTTP connections. </p>
</div>
<h3><a name="12562">setPort</a></h3>
<p class="decl">void setPort(<br /> <a href="Poco.html#11352" title="Poco::UInt16">Poco::UInt16</a> port<br />);</p>
<div class="description">
<p>Sets the port number of the target HTTP server. </p>
<p>The port number must not be changed once there is an open connection to the server. </p>
</div>
<h3><a name="12565">setProxy</a></h3>
<p class="decl">void setProxy(<br /> const std::string & host,<br /> <a href="Poco.html#11352" title="Poco::UInt16">Poco::UInt16</a> port = HTTPSession::HTTP_PORT<br />);</p>
<div class="description">
<p>Sets the proxy host name and port number. </p>
</div>
<h3><a name="12568">setProxyHost</a></h3>
<p class="decl">void setProxyHost(<br /> const std::string & host<br />);</p>
<div class="description">
<p>Sets the host name of the proxy server. </p>
</div>
<h3><a name="12570">setProxyPort</a></h3>
<p class="decl">void setProxyPort(<br /> <a href="Poco.html#11352" title="Poco::UInt16">Poco::UInt16</a> port<br />);</p>
<div class="description">
<p>Sets the port number of the proxy server. </p>
</div>
<h3><a name="12589">deleteRequestStream</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void deleteRequestStream();</p>
<div class="description">
<p>Deletes the request stream and sets it to 0. </p>
</div>
<h3><a name="12588">deleteResponseStream</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void deleteResponseStream();</p>
<div class="description">
<p>Deletes the response stream and sets it to 0. </p>
</div>
<h3><a name="12600">getExpectResponseBody</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool getExpectResponseBody() const;</p>
<div class="description">
<p>Returns _expectResponseBody. </p>
</div>
<h3><a name="12595">getRequestStream</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">std::ostream * getRequestStream() const;</p>
<div class="description">
<p>Returns the currently set request stream. Can return 0. </p>
</div>
<h3><a name="12594">getResponseStream</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">std::istream * getResponseStream() const;</p>
<div class="description">
<p>Returns the currently set response stream. Can return 0. </p>
</div>
<h3><a name="12601">mustReconnect</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool mustReconnect() const;</p>
<div class="description">
<p>Checks if we can reuse a persistent connection. </p>
</div>
<h3><a name="12587">proxyRequestPrefix</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual std::string proxyRequestPrefix() const;</p>
<div class="description">
<p>Returns the prefix prepended to the <a href="Poco.URI.html" title="class Poco::URI">URI</a> for proxy requests (e.g., "<a href="http://myhost.com"" target="_blank">http://myhost.com"</a>). </p>
</div>
<h3><a name="12583">reconnect</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void reconnect();</p>
<div class="description">
<p>Connects the underlying socket to the HTTP server. </p>
</div>
<h3><a name="12598">setExpectResponseBody</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setExpectResponseBody(<br /> bool expect<br />);</p>
<div class="description">
<p>Sets _expectResponseBody. </p>
</div>
<h3><a name="12596">setReconnect</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setReconnect(<br /> bool recon<br />);</p>
<div class="description">
<p>Sets _reconnect. </p>
</div>
<h3><a name="12592">setRequestStream</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setRequestStream(<br /> std::ostream * pRequestStream<br />);</p>
<div class="description">
<p>Sets the request stream if and only if _pRequestStream is 0. </p>
</div>
<h3><a name="12590">setResponseStream</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setResponseStream(<br /> std::istream * pRespStream<br />);</p>
<div class="description">
<p>Sets the response stream if and only if _pResponseStream is 0. </p>
</div>
<h3><a name="12584">write</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">int write(<br /> const char * buffer,<br /> std::streamsize length<br />);</p>
<div class="description">
<p>Tries to re-connect if keep-alive is on. </p>
</div>
<div class="description"><p><b>See also:</b> <a href="Poco.Net.HTTPSession.html#13186" title="Poco::Net::HTTPSession::write()">Poco::Net::HTTPSession::write()</a></p></div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>
</div>
</body>
</html>
|