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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
|
<!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>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Wt: Wt::Http::Client Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Wt
 <span id="projectnumber">3.2.1</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="inherits.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespaceWt.html">Wt</a> </li>
<li class="navelem"><a class="el" href="namespaceWt_1_1Http.html">Http</a> </li>
<li class="navelem"><a class="el" href="classWt_1_1Http_1_1Client.html">Client</a> </li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#nested-classes">Classes</a> |
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pub-static-methods">Static Public Member Functions</a> </div>
<div class="headertitle">
<div class="title">Wt::Http::Client Class Reference<div class="ingroups"><a class="el" href="group__http.html">HTTP protocol (Wt::Http)</a></div></div> </div>
</div>
<div class="contents">
<!-- doxytag: class="Wt::Http::Client" --><!-- doxytag: inherits="Wt::WObject" -->
<p>An HTTP client.
<a href="classWt_1_1Http_1_1Client.html#details">More...</a></p>
<p><code>#include <Wt/Http/Client></code></p>
<div class="dynheader">
Inheritance diagram for Wt::Http::Client:</div>
<div class="dyncontent">
<div class="center"><img src="classWt_1_1Http_1_1Client__inherit__graph.png" border="0" usemap="#Wt_1_1Http_1_1Client_inherit__map" alt="Inheritance graph"/></div>
<map name="Wt_1_1Http_1_1Client_inherit__map" id="Wt_1_1Http_1_1Client_inherit__map">
<area shape="rect" href="classWt_1_1WObject.html" title="A base class for objects that participate in the signal/slot system." alt="" coords="13,5,109,32"/></map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<p><a href="classWt_1_1Http_1_1Client-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct  </td><td class="memItemRight" valign="bottom"><a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html">URL</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This struct implements an <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> data structure. <a href="structWt_1_1Http_1_1Client_1_1URL.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#ae61882b1de0a4965ca8053139e1fdc5b">Client</a> (<a class="el" href="classWt_1_1WObject.html">WObject</a> *parent=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#ae61882b1de0a4965ca8053139e1fdc5b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a6de4a3b49f1e15e4d38ffd7fa3463de1">Client</a> (<a class="el" href="classWt_1_1WIOService.html">WIOService</a> &ioService, <a class="el" href="classWt_1_1WObject.html">WObject</a> *parent=0)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#a6de4a3b49f1e15e4d38ffd7fa3463de1"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a7da4dec8f24f8215f87efffbd20657e3">~Client</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#a7da4dec8f24f8215f87efffbd20657e3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a8028fe5ce7d0b005d076c3e69f629b83">setTimeout</a> (int seconds)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets an I/O timeout. <a href="#a8028fe5ce7d0b005d076c3e69f629b83"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a3853ca1ea04a24e94eb02e14370f79f3">timeout</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the I/O timeout. <a href="#a3853ca1ea04a24e94eb02e14370f79f3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a45b25de10c5da7c7c5abf0892593a04d">setMaximumResponseSize</a> (std::size_t bytes)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets a maximum response size. <a href="#a45b25de10c5da7c7c5abf0892593a04d"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">std::size_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#aa0570ee898bc9bd34cbf1b960bd87e44">maximumResponseSize</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the maximum response size. <a href="#aa0570ee898bc9bd34cbf1b960bd87e44"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#ac6b8b35ab2813a22c3c2e2ae7d1f9a35">setSslVerifyFile</a> (const std::string &verifyFile)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets a SSL certificate used for server identity verification. <a href="#ac6b8b35ab2813a22c3c2e2ae7d1f9a35"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a7c9fbf7fc9f671519b0652f3bbe38521">setSslVerifyPath</a> (const std::string &verifyPath)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sets a path with SSL certificates for server identity verification. <a href="#a7c9fbf7fc9f671519b0652f3bbe38521"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a1bf5f26230279a99fa1429ab84315458">get</a> (const std::string &url)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Starts a GET request. <a href="#a1bf5f26230279a99fa1429ab84315458"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#ab8b9fe9ff278c5a8cb97125ed3671bb3">get</a> (const std::string &url, const std::vector< <a class="el" href="classWt_1_1Http_1_1Message_1_1Header.html">Message::Header</a> > headers)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Starts a GET request. <a href="#ab8b9fe9ff278c5a8cb97125ed3671bb3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a2b5cad895252510ff1cd0e8e6e31c453">post</a> (const std::string &url, const <a class="el" href="classWt_1_1Http_1_1Message.html">Message</a> &message)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Starts a POST request. <a href="#a2b5cad895252510ff1cd0e8e6e31c453"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#aed50841f6c792d8f08e44225401abab0">request</a> (Http::Method method, const std::string &url, const <a class="el" href="classWt_1_1Http_1_1Message.html">Message</a> &message)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Starts a request. <a href="#aed50841f6c792d8f08e44225401abab0"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#ac2a756dec030880f02bb3411469c737e">abort</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Aborts the curent request. <a href="#ac2a756dec030880f02bb3411469c737e"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classWt_1_1Signal.html">Signal</a><br class="typebreak"/>
< boost::system::error_code, <br class="typebreak"/>
<a class="el" href="classWt_1_1Http_1_1Message.html">Message</a> > & </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb">done</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Signal that is emitted when the current request is done. <a href="#aef3aee01b919b503f9bcb2042819b5fb"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classWt_1_1Http_1_1Client.html#a7855c34bd3d468a53d1d75446a358724">parseUrl</a> (const std::string &url, <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html">URL</a> &parsedUrl)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Utility method to parse a <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a>. <a href="#a7855c34bd3d468a53d1d75446a358724"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>An HTTP client. </p>
<p>This class implements an HTTP client. It can be used to interact with web services using the HTTP protocol.</p>
<p>The client uses asynchronous I/O and only provides an asynchronous interface: you cannot actively wait for an operation to complete, instead the client will notify you of the result using the <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> signal.</p>
<p>Because the client uses asynchronous I/O, it does its work within the scope of an event-driven thread pool implementation. By default, this is the same thread pool that is used by the Wt server, available through <a class="el" href="classWt_1_1WServer.html#a8e1945f6fc8013457037bc7280f5cfaa" title="Returns the I/O service.">WServer::ioService()</a>, but you may also use the client by providing it an explicit I/O service to be used.</p>
<p>The client supports the HTTP and HTTPS (if Wt was built with OpenSSL support) protocols, and can be used for GET and POST methods. One client can do only one operation at a time.</p>
<p>Usage example: </p>
<div class="fragment"><pre class="fragment"> ...
Http::Client *client = <span class="keyword">new</span> <a class="code" href="classWt_1_1Http_1_1Client.html#ae61882b1de0a4965ca8053139e1fdc5b" title="Default constructor.">Http::Client</a>(<span class="keyword">this</span>);
client->setTimeout(15);
client->setMaximumResponseSize(10 * 1024);
client->done().connect(boost::bind(&MyWidget::handleHttpResponse, <span class="keyword">this</span>, _1, _2));
<span class="keywordflow">if</span> (client->get(<span class="stringliteral">"http://www.webtoolkit.eu/wt/blog/feed/"</span>))
<a class="code" href="classWt_1_1WApplication.html#a38d922da0a0d83395519f3eaab85d0f6" title="Returns the current application instance.">WApplication::instance</a>()->deferRendering();
} <span class="keywordflow">else</span> {
<span class="comment">// in case of an error in the URL</span>
}
}
<span class="keywordtype">void</span> handleHttpResponse(boost::system::error_code err, <span class="keyword">const</span> Http::Message& response)
{
<a class="code" href="classWt_1_1WApplication.html#a38d922da0a0d83395519f3eaab85d0f6" title="Returns the current application instance.">WApplication::instance</a>()->resumeRendering();
<span class="keywordflow">if</span> (!err && response.status() == 200) {
... <a class="code" href="group__json.html#gaf4a7b6b9993d7dc37c1ffd035cfba5e7" title="Parse function.">parse</a> response.body()
}
}
</pre></div><p>The function connected to the <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> signal will be run within the context of the application that created the client. <a class="el" href="classWt_1_1WServer.html#a6115cc9ad6ec28e55fb85e32a045df88" title="Posts a function to a session.">WServer::post()</a> is used for this. </p>
</div><hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="ae61882b1de0a4965ca8053139e1fdc5b"></a><!-- doxytag: member="Wt::Http::Client::Client" ref="ae61882b1de0a4965ca8053139e1fdc5b" args="(WObject *parent=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Wt::Http::Client::Client </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classWt_1_1WObject.html">WObject</a> * </td>
<td class="paramname"><em>parent</em> = <code>0</code></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Default constructor. </p>
<p>The client uses the I/O service and thread-pool from the current <a class="el" href="classWt_1_1WApplication.html#a38d922da0a0d83395519f3eaab85d0f6" title="Returns the current application instance.">WApplication::instance()</a>. </p>
</div>
</div>
<a class="anchor" id="a6de4a3b49f1e15e4d38ffd7fa3463de1"></a><!-- doxytag: member="Wt::Http::Client::Client" ref="a6de4a3b49f1e15e4d38ffd7fa3463de1" args="(WIOService &ioService, WObject *parent=0)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Wt::Http::Client::Client </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classWt_1_1WIOService.html">WIOService</a> & </td>
<td class="paramname"><em>ioService</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="classWt_1_1WObject.html">WObject</a> * </td>
<td class="paramname"><em>parent</em> = <code>0</code> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Constructor. </p>
<p>The client uses the given I/O service and thread-pool, and is useful to use the client outside the context of a web application. </p>
</div>
</div>
<a class="anchor" id="a7da4dec8f24f8215f87efffbd20657e3"></a><!-- doxytag: member="Wt::Http::Client::~Client" ref="a7da4dec8f24f8215f87efffbd20657e3" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Wt::Http::Client::~Client </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td><code> [virtual]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Destructor. </p>
<p>If the client is still busy, the current request is aborted.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#ac2a756dec030880f02bb3411469c737e" title="Aborts the curent request.">abort()</a> </dd></dl>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="ac2a756dec030880f02bb3411469c737e"></a><!-- doxytag: member="Wt::Http::Client::abort" ref="ac2a756dec030880f02bb3411469c737e" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::Http::Client::abort </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Aborts the curent request. </p>
<p>If the client is currently busy, this cancels the pending request. <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> will be emitted with an error_code. (FIXME: which one ?) </p>
</div>
</div>
<a class="anchor" id="aef3aee01b919b503f9bcb2042819b5fb"></a><!-- doxytag: member="Wt::Http::Client::done" ref="aef3aee01b919b503f9bcb2042819b5fb" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classWt_1_1Signal.html">Signal</a><boost::system::error_code, <a class="el" href="classWt_1_1Http_1_1Message.html">Message</a>>& Wt::Http::Client::done </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Signal that is emitted when the current request is done. </p>
<p>The <code>error</code> is 0 if the HTTP request was successful. Then, the <code>message</code> contains the result.</p>
<p>If the <code>error</code> is not 0, then an error message is given by <code>error.message()</code>.</p>
<p>Typical code to process the result is: </p>
<div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> handle(boost::system::error_code err, <span class="keyword">const</span> Http::Message& response)
{
<span class="keywordflow">if</span> (!err) {
<span class="keywordflow">if</span> (response.status() == 200) {
... success
}
} <span class="keywordflow">else</span> {
Wt::log(<span class="stringliteral">"error"</span>) << <span class="stringliteral">"Http::Client error: "</span> << err.message();
}
}
</pre></div>
</div>
</div>
<a class="anchor" id="a1bf5f26230279a99fa1429ab84315458"></a><!-- doxytag: member="Wt::Http::Client::get" ref="a1bf5f26230279a99fa1429ab84315458" args="(const std::string &url)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Wt::Http::Client::get </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>url</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Starts a GET request. </p>
<p>The function starts an asynchronous GET request, and returns immediately.</p>
<p>The function returns <code>true</code> when the GET request has been scheduled, and thus <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> will be emitted eventually.</p>
<p>The function returns <code>false</code> if the client could not schedule the request, for example if the <code>url</code> is invalid or if the <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> scheme is not supported.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#aed50841f6c792d8f08e44225401abab0" title="Starts a request.">request()</a>, <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ab8b9fe9ff278c5a8cb97125ed3671bb3"></a><!-- doxytag: member="Wt::Http::Client::get" ref="ab8b9fe9ff278c5a8cb97125ed3671bb3" args="(const std::string &url, const std::vector< Message::Header > headers)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Wt::Http::Client::get </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>url</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector< <a class="el" href="classWt_1_1Http_1_1Message_1_1Header.html">Message::Header</a> > </td>
<td class="paramname"><em>headers</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Starts a GET request. </p>
<p>The function starts an asynchronous GET request, and returns immediately.</p>
<p>The function returns <code>true</code> when the GET request has been scheduled, and thus <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> will be emitted eventually.</p>
<p>The function returns <code>false</code> if the client could not schedule the request, for example if the <code>url</code> is invalid or if the <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> scheme is not supported.</p>
<p>This function accepts one or more headers.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#aed50841f6c792d8f08e44225401abab0" title="Starts a request.">request()</a>, <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="aa0570ee898bc9bd34cbf1b960bd87e44"></a><!-- doxytag: member="Wt::Http::Client::maximumResponseSize" ref="aa0570ee898bc9bd34cbf1b960bd87e44" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">std::size_t Wt::Http::Client::maximumResponseSize </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns the maximum response size. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#a45b25de10c5da7c7c5abf0892593a04d" title="Sets a maximum response size.">setMaximumResponseSize()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a7855c34bd3d468a53d1d75446a358724"></a><!-- doxytag: member="Wt::Http::Client::parseUrl" ref="a7855c34bd3d468a53d1d75446a358724" args="(const std::string &url, URL &parsedUrl)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Wt::Http::Client::parseUrl </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>url</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html">URL</a> & </td>
<td class="paramname"><em>parsedUrl</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Utility method to parse a <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a>. </p>
<p>This parses a <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> into the <code>parsedUrl</code> object.</p>
<p>The method returns true if the <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> could be parsed successfully. </p>
</div>
</div>
<a class="anchor" id="a2b5cad895252510ff1cd0e8e6e31c453"></a><!-- doxytag: member="Wt::Http::Client::post" ref="a2b5cad895252510ff1cd0e8e6e31c453" args="(const std::string &url, const Message &message)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Wt::Http::Client::post </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>url</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classWt_1_1Http_1_1Message.html">Message</a> & </td>
<td class="paramname"><em>message</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Starts a POST request. </p>
<p>The function starts an asynchronous POST request, and returns immediately.</p>
<p>The function returns <code>true</code> when the POST request has been scheduled, and thus <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> will be emitted eventually.</p>
<p>The function returns <code>false</code> if the client could not schedule the request, for example if the <code>url</code> is invalid or if the <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> scheme is not supported.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#aed50841f6c792d8f08e44225401abab0" title="Starts a request.">request()</a>, <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="aed50841f6c792d8f08e44225401abab0"></a><!-- doxytag: member="Wt::Http::Client::request" ref="aed50841f6c792d8f08e44225401abab0" args="(Http::Method method, const std::string &url, const Message &message)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool Wt::Http::Client::request </td>
<td>(</td>
<td class="paramtype">Http::Method </td>
<td class="paramname"><em>method</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>url</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classWt_1_1Http_1_1Message.html">Message</a> & </td>
<td class="paramname"><em>message</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Starts a request. </p>
<p>The function starts an asynchronous HTTP request, and returns immediately.</p>
<p>The function returns <code>true</code> when the request has been scheduled, and thus <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> will be emitted eventually.</p>
<p>The function returns <code>false</code> if the client could not schedule the request, for example if the <code>url</code> is invalid or if the <a class="el" href="structWt_1_1Http_1_1Client_1_1URL.html" title="This struct implements an URL data structure.">URL</a> scheme is not supported.</p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#aed50841f6c792d8f08e44225401abab0" title="Starts a request.">request()</a>, <a class="el" href="classWt_1_1Http_1_1Client.html#aef3aee01b919b503f9bcb2042819b5fb" title="Signal that is emitted when the current request is done.">done()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="a45b25de10c5da7c7c5abf0892593a04d"></a><!-- doxytag: member="Wt::Http::Client::setMaximumResponseSize" ref="a45b25de10c5da7c7c5abf0892593a04d" args="(std::size_t bytes)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::Http::Client::setMaximumResponseSize </td>
<td>(</td>
<td class="paramtype">std::size_t </td>
<td class="paramname"><em>bytes</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sets a maximum response size. </p>
<p>The response is stored in-memory. To avoid a DoS by a malicious downstream HTTP server, the response size is bounded by an upper limit.</p>
<p>The limit includes status line, headers and response body.</p>
<p>The default value is 64 kilo bytes. </p>
</div>
</div>
<a class="anchor" id="ac6b8b35ab2813a22c3c2e2ae7d1f9a35"></a><!-- doxytag: member="Wt::Http::Client::setSslVerifyFile" ref="ac6b8b35ab2813a22c3c2e2ae7d1f9a35" args="(const std::string &verifyFile)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::Http::Client::setSslVerifyFile </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>verifyFile</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sets a SSL certificate used for server identity verification. </p>
<p>This setting only affects a https request: it configures a certificate file to be used to verify the identity of the server.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>Certificate verification does not work reliably yet. </dd></dl>
</div>
</div>
<a class="anchor" id="a7c9fbf7fc9f671519b0652f3bbe38521"></a><!-- doxytag: member="Wt::Http::Client::setSslVerifyPath" ref="a7c9fbf7fc9f671519b0652f3bbe38521" args="(const std::string &verifyPath)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::Http::Client::setSslVerifyPath </td>
<td>(</td>
<td class="paramtype">const std::string & </td>
<td class="paramname"><em>verifyPath</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sets a path with SSL certificates for server identity verification. </p>
<p>This setting only affects a https request: it configures a directory containing certificates to be used to verify the identity of the server.</p>
<dl class="note"><dt><b>Note:</b></dt><dd>Certificate verification does not work reliably yet. </dd></dl>
</div>
</div>
<a class="anchor" id="a8028fe5ce7d0b005d076c3e69f629b83"></a><!-- doxytag: member="Wt::Http::Client::setTimeout" ref="a8028fe5ce7d0b005d076c3e69f629b83" args="(int seconds)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void Wt::Http::Client::setTimeout </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>seconds</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Sets an I/O timeout. </p>
<p>This sets a timeout wiating for I/O operations. The timeout does not bound the total timeout, since the timer is reset on each I/O progress.</p>
<p>The default timeout is 10 seconds. </p>
</div>
</div>
<a class="anchor" id="a3853ca1ea04a24e94eb02e14370f79f3"></a><!-- doxytag: member="Wt::Http::Client::timeout" ref="a3853ca1ea04a24e94eb02e14370f79f3" args="() const " -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int Wt::Http::Client::timeout </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Returns the I/O timeout. </p>
<dl class="see"><dt><b>See also:</b></dt><dd><a class="el" href="classWt_1_1Http_1_1Client.html#a8028fe5ce7d0b005d076c3e69f629b83" title="Sets an I/O timeout.">setTimeout()</a> </dd></dl>
</div>
</div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<hr size="1"><address style="text-align: right; margin: 3px"><small>
Generated on Fri Mar 30 2012 for <a href="http://www.webtoolkit.eu/wt">the
C++ Web Toolkit (Wt)</a> by <a
href="http://www.doxygen.org/index.html"><img src="doxygen.png"
alt="doxygen" border="0" style="vertical-align: middle; display:
inline-block; height: 2em"></a> 1.7.5.1</small></address>
</body>
</html>
|