1 <?xml version="1.0" encoding="ascii"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 3 "DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 5 <head> 6 <title>googleapiclient.http</title> 7 <link rel="stylesheet" href="epydoc.css" type="text/css" /> 8 <script type="text/javascript" src="epydoc.js"></script> 9 </head> 10 11 <body bgcolor="white" text="black" link="blue" vlink="#204080" 12 alink="#204080"> 13 <!-- ==================== NAVIGATION BAR ==================== --> 14 <table class="navbar" border="0" width="100%" cellpadding="0" 15 bgcolor="#a0c0ff" cellspacing="0"> 16 <tr valign="middle"> 17 <!-- Home link --> 18 <th> <a 19 href="googleapiclient-module.html">Home</a> </th> 20 21 <!-- Tree link --> 22 <th> <a 23 href="module-tree.html">Trees</a> </th> 24 25 <!-- Index link --> 26 <th> <a 27 href="identifier-index.html">Indices</a> </th> 28 29 <!-- Help link --> 30 <th> <a 31 href="help.html">Help</a> </th> 32 33 <th class="navbar" width="100%"></th> 34 </tr> 35 </table> 36 <table width="100%" cellpadding="0" cellspacing="0"> 37 <tr valign="top"> 38 <td width="100%"> 39 <span class="breadcrumbs"> 40 <a href="googleapiclient-module.html">Package googleapiclient</a> :: 41 Module http 42 </span> 43 </td> 44 <td> 45 <table cellpadding="0" cellspacing="0"> 46 <!-- hide/show private --> 47 <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" 48 onclick="toggle_private();">hide private</a>]</span></td></tr> 49 <tr><td align="right"><span class="options" 50 >[<a href="frames.html" target="_top">frames</a 51 >] | <a href="googleapiclient.http-module.html" 52 target="_top">no frames</a>]</span></td></tr> 53 </table> 54 </td> 55 </tr> 56 </table> 57 <!-- ==================== MODULE DESCRIPTION ==================== --> 58 <h1 class="epydoc">Module http</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html">source code</a></span></p> 59 <pre class="literalblock"> 60 Classes to encapsulate a single HTTP request. 61 62 The classes implement a command pattern, with every 63 object supporting an execute() method that does the 64 actuall HTTP request. 65 66 </pre> 67 68 <hr /> 69 <div class="fields"> <p><strong>Author:</strong> 70 jcgregorio (a] google.com (Joe Gregorio) 71 </p> 72 </div><!-- ==================== CLASSES ==================== --> 73 <a name="section-Classes"></a> 74 <table class="summary" border="1" cellpadding="3" 75 cellspacing="0" width="100%" bgcolor="white"> 76 <tr bgcolor="#70b0f0" class="table-header"> 77 <td colspan="2" class="table-header"> 78 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 79 <tr valign="top"> 80 <td align="left"><span class="table-header">Classes</span></td> 81 <td align="right" valign="top" 82 ><span class="options">[<a href="#section-Classes" 83 class="privatelink" onclick="toggle_private();" 84 >hide private</a>]</span></td> 85 </tr> 86 </table> 87 </td> 88 </tr> 89 <tr> 90 <td width="15%" align="right" valign="top" class="summary"> 91 <span class="summary-type"> </span> 92 </td><td class="summary"> 93 <a href="googleapiclient.http.MediaUploadProgress-class.html" class="summary-name">MediaUploadProgress</a><br /> 94 Status of a resumable upload. 95 </td> 96 </tr> 97 <tr> 98 <td width="15%" align="right" valign="top" class="summary"> 99 <span class="summary-type"> </span> 100 </td><td class="summary"> 101 <a href="googleapiclient.http.MediaDownloadProgress-class.html" class="summary-name">MediaDownloadProgress</a><br /> 102 Status of a resumable download. 103 </td> 104 </tr> 105 <tr> 106 <td width="15%" align="right" valign="top" class="summary"> 107 <span class="summary-type"> </span> 108 </td><td class="summary"> 109 <a href="googleapiclient.http.MediaUpload-class.html" class="summary-name">MediaUpload</a><br /> 110 Describes a media object to upload. 111 </td> 112 </tr> 113 <tr> 114 <td width="15%" align="right" valign="top" class="summary"> 115 <span class="summary-type"> </span> 116 </td><td class="summary"> 117 <a href="googleapiclient.http.MediaIoBaseUpload-class.html" class="summary-name">MediaIoBaseUpload</a><br /> 118 A MediaUpload for a io.Base objects. 119 </td> 120 </tr> 121 <tr> 122 <td width="15%" align="right" valign="top" class="summary"> 123 <span class="summary-type"> </span> 124 </td><td class="summary"> 125 <a href="googleapiclient.http.MediaFileUpload-class.html" class="summary-name">MediaFileUpload</a><br /> 126 A MediaUpload for a file. 127 </td> 128 </tr> 129 <tr> 130 <td width="15%" align="right" valign="top" class="summary"> 131 <span class="summary-type"> </span> 132 </td><td class="summary"> 133 <a href="googleapiclient.http.MediaInMemoryUpload-class.html" class="summary-name">MediaInMemoryUpload</a><br /> 134 MediaUpload for a chunk of bytes. 135 </td> 136 </tr> 137 <tr> 138 <td width="15%" align="right" valign="top" class="summary"> 139 <span class="summary-type"> </span> 140 </td><td class="summary"> 141 <a href="googleapiclient.http.MediaIoBaseDownload-class.html" class="summary-name">MediaIoBaseDownload</a><br /> 142 "Download media resources. 143 </td> 144 </tr> 145 <tr class="private"> 146 <td width="15%" align="right" valign="top" class="summary"> 147 <span class="summary-type"> </span> 148 </td><td class="summary"> 149 <a href="googleapiclient.http._StreamSlice-class.html" class="summary-name" onclick="show_private();">_StreamSlice</a><br /> 150 Truncated stream. 151 </td> 152 </tr> 153 <tr> 154 <td width="15%" align="right" valign="top" class="summary"> 155 <span class="summary-type"> </span> 156 </td><td class="summary"> 157 <a href="googleapiclient.http.HttpRequest-class.html" class="summary-name">HttpRequest</a><br /> 158 Encapsulates a single HTTP request. 159 </td> 160 </tr> 161 <tr> 162 <td width="15%" align="right" valign="top" class="summary"> 163 <span class="summary-type"> </span> 164 </td><td class="summary"> 165 <a href="googleapiclient.http.BatchHttpRequest-class.html" class="summary-name">BatchHttpRequest</a><br /> 166 Batches multiple HttpRequest objects into a single HTTP request. 167 </td> 168 </tr> 169 <tr> 170 <td width="15%" align="right" valign="top" class="summary"> 171 <span class="summary-type"> </span> 172 </td><td class="summary"> 173 <a href="googleapiclient.http.HttpRequestMock-class.html" class="summary-name">HttpRequestMock</a><br /> 174 Mock of HttpRequest. 175 </td> 176 </tr> 177 <tr> 178 <td width="15%" align="right" valign="top" class="summary"> 179 <span class="summary-type"> </span> 180 </td><td class="summary"> 181 <a href="googleapiclient.http.RequestMockBuilder-class.html" class="summary-name">RequestMockBuilder</a><br /> 182 A simple mock of HttpRequest 183 </td> 184 </tr> 185 <tr> 186 <td width="15%" align="right" valign="top" class="summary"> 187 <span class="summary-type"> </span> 188 </td><td class="summary"> 189 <a href="googleapiclient.http.HttpMock-class.html" class="summary-name">HttpMock</a><br /> 190 Mock of httplib2.Http 191 </td> 192 </tr> 193 <tr> 194 <td width="15%" align="right" valign="top" class="summary"> 195 <span class="summary-type"> </span> 196 </td><td class="summary"> 197 <a href="googleapiclient.http.HttpMockSequence-class.html" class="summary-name">HttpMockSequence</a><br /> 198 Mock of httplib2.Http 199 </td> 200 </tr> 201 </table> 202 <!-- ==================== FUNCTIONS ==================== --> 203 <a name="section-Functions"></a> 204 <table class="summary" border="1" cellpadding="3" 205 cellspacing="0" width="100%" bgcolor="white"> 206 <tr bgcolor="#70b0f0" class="table-header"> 207 <td colspan="2" class="table-header"> 208 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 209 <tr valign="top"> 210 <td align="left"><span class="table-header">Functions</span></td> 211 <td align="right" valign="top" 212 ><span class="options">[<a href="#section-Functions" 213 class="privatelink" onclick="toggle_private();" 214 >hide private</a>]</span></td> 215 </tr> 216 </table> 217 </td> 218 </tr> 219 <tr class="private"> 220 <td width="15%" align="right" valign="top" class="summary"> 221 <span class="summary-type"> </span> 222 </td><td class="summary"> 223 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 224 <tr> 225 <td><span class="summary-sig"><a href="googleapiclient.http-module.html#_should_retry_response" class="summary-sig-name" onclick="show_private();">_should_retry_response</a>(<span class="summary-sig-arg">resp_status</span>, 226 <span class="summary-sig-arg">content</span>)</span><br /> 227 Determines whether a response should be retried.</td> 228 <td align="right" valign="top"> 229 <span class="codelink"><a href="googleapiclient.http-pysrc.html#_should_retry_response">source code</a></span> 230 231 </td> 232 </tr> 233 </table> 234 235 </td> 236 </tr> 237 <tr class="private"> 238 <td width="15%" align="right" valign="top" class="summary"> 239 <span class="summary-type"> </span> 240 </td><td class="summary"> 241 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 242 <tr> 243 <td><span class="summary-sig"><a href="googleapiclient.http-module.html#_retry_request" class="summary-sig-name" onclick="show_private();">_retry_request</a>(<span class="summary-sig-arg">http</span>, 244 <span class="summary-sig-arg">num_retries</span>, 245 <span class="summary-sig-arg">req_type</span>, 246 <span class="summary-sig-arg">sleep</span>, 247 <span class="summary-sig-arg">rand</span>, 248 <span class="summary-sig-arg">uri</span>, 249 <span class="summary-sig-arg">method</span>, 250 <span class="summary-sig-arg">*args</span>, 251 <span class="summary-sig-arg">**kwargs</span>)</span><br /> 252 Retries an HTTP request multiple times while handling errors.</td> 253 <td align="right" valign="top"> 254 <span class="codelink"><a href="googleapiclient.http-pysrc.html#_retry_request">source code</a></span> 255 256 </td> 257 </tr> 258 </table> 259 260 </td> 261 </tr> 262 <tr> 263 <td width="15%" align="right" valign="top" class="summary"> 264 <span class="summary-type"> </span> 265 </td><td class="summary"> 266 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 267 <tr> 268 <td><span class="summary-sig"><a href="googleapiclient.http-module.html#set_user_agent" class="summary-sig-name">set_user_agent</a>(<span class="summary-sig-arg">http</span>, 269 <span class="summary-sig-arg">user_agent</span>)</span><br /> 270 Set the user-agent on every request.</td> 271 <td align="right" valign="top"> 272 <span class="codelink"><a href="googleapiclient.http-pysrc.html#set_user_agent">source code</a></span> 273 274 </td> 275 </tr> 276 </table> 277 278 </td> 279 </tr> 280 <tr> 281 <td width="15%" align="right" valign="top" class="summary"> 282 <span class="summary-type"> </span> 283 </td><td class="summary"> 284 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 285 <tr> 286 <td><span class="summary-sig"><a href="googleapiclient.http-module.html#tunnel_patch" class="summary-sig-name">tunnel_patch</a>(<span class="summary-sig-arg">http</span>)</span><br /> 287 Tunnel PATCH requests over POST.</td> 288 <td align="right" valign="top"> 289 <span class="codelink"><a href="googleapiclient.http-pysrc.html#tunnel_patch">source code</a></span> 290 291 </td> 292 </tr> 293 </table> 294 295 </td> 296 </tr> 297 <tr> 298 <td width="15%" align="right" valign="top" class="summary"> 299 <span class="summary-type"> </span> 300 </td><td class="summary"> 301 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 302 <tr> 303 <td><span class="summary-sig"><a href="googleapiclient.http-module.html#build_http" class="summary-sig-name">build_http</a>()</span><br /> 304 Builds httplib2.Http object</td> 305 <td align="right" valign="top"> 306 <span class="codelink"><a href="googleapiclient.http-pysrc.html#build_http">source code</a></span> 307 308 </td> 309 </tr> 310 </table> 311 312 </td> 313 </tr> 314 </table> 315 <!-- ==================== VARIABLES ==================== --> 316 <a name="section-Variables"></a> 317 <table class="summary" border="1" cellpadding="3" 318 cellspacing="0" width="100%" bgcolor="white"> 319 <tr bgcolor="#70b0f0" class="table-header"> 320 <td colspan="2" class="table-header"> 321 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 322 <tr valign="top"> 323 <td align="left"><span class="table-header">Variables</span></td> 324 <td align="right" valign="top" 325 ><span class="options">[<a href="#section-Variables" 326 class="privatelink" onclick="toggle_private();" 327 >hide private</a>]</span></td> 328 </tr> 329 </table> 330 </td> 331 </tr> 332 <tr class="private"> 333 <td width="15%" align="right" valign="top" class="summary"> 334 <span class="summary-type"> </span> 335 </td><td class="summary"> 336 <a name="_ssl_SSLError"></a><span class="summary-name">_ssl_SSLError</span> = <code title="ssl.SSLError">ssl.SSLError</code> 337 </td> 338 </tr> 339 <tr> 340 <td width="15%" align="right" valign="top" class="summary"> 341 <span class="summary-type"> </span> 342 </td><td class="summary"> 343 <a name="LOGGER"></a><span class="summary-name">LOGGER</span> = <code title="logging.getLogger(__name__)">logging.getLogger(__name__)</code> 344 </td> 345 </tr> 346 <tr> 347 <td width="15%" align="right" valign="top" class="summary"> 348 <span class="summary-type"> </span> 349 </td><td class="summary"> 350 <a name="DEFAULT_CHUNK_SIZE"></a><span class="summary-name">DEFAULT_CHUNK_SIZE</span> = <code title="512* 1024">512* 1024</code> 351 </td> 352 </tr> 353 <tr> 354 <td width="15%" align="right" valign="top" class="summary"> 355 <span class="summary-type"> </span> 356 </td><td class="summary"> 357 <a name="MAX_URI_LENGTH"></a><span class="summary-name">MAX_URI_LENGTH</span> = <code title="2048">2048</code> 358 </td> 359 </tr> 360 <tr class="private"> 361 <td width="15%" align="right" valign="top" class="summary"> 362 <span class="summary-type"> </span> 363 </td><td class="summary"> 364 <a name="_TOO_MANY_REQUESTS"></a><span class="summary-name">_TOO_MANY_REQUESTS</span> = <code title="429">429</code> 365 </td> 366 </tr> 367 <tr> 368 <td width="15%" align="right" valign="top" class="summary"> 369 <span class="summary-type"> </span> 370 </td><td class="summary"> 371 <a name="DEFAULT_HTTP_TIMEOUT_SEC"></a><span class="summary-name">DEFAULT_HTTP_TIMEOUT_SEC</span> = <code title="60">60</code> 372 </td> 373 </tr> 374 </table> 375 <!-- ==================== FUNCTION DETAILS ==================== --> 376 <a name="section-FunctionDetails"></a> 377 <table class="details" border="1" cellpadding="3" 378 cellspacing="0" width="100%" bgcolor="white"> 379 <tr bgcolor="#70b0f0" class="table-header"> 380 <td colspan="2" class="table-header"> 381 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 382 <tr valign="top"> 383 <td align="left"><span class="table-header">Function Details</span></td> 384 <td align="right" valign="top" 385 ><span class="options">[<a href="#section-FunctionDetails" 386 class="privatelink" onclick="toggle_private();" 387 >hide private</a>]</span></td> 388 </tr> 389 </table> 390 </td> 391 </tr> 392 </table> 393 <a name="_should_retry_response"></a> 394 <div class="private"> 395 <table class="details" border="1" cellpadding="3" 396 cellspacing="0" width="100%" bgcolor="white"> 397 <tr><td> 398 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 399 <tr valign="top"><td> 400 <h3 class="epydoc"><span class="sig"><span class="sig-name">_should_retry_response</span>(<span class="sig-arg">resp_status</span>, 401 <span class="sig-arg">content</span>)</span> 402 </h3> 403 </td><td align="right" valign="top" 404 ><span class="codelink"><a href="googleapiclient.http-pysrc.html#_should_retry_response">source code</a></span> 405 </td> 406 </tr></table> 407 408 <pre class="literalblock"> 409 Determines whether a response should be retried. 410 411 Args: 412 resp_status: The response status received. 413 content: The response content body. 414 415 Returns: 416 True if the response should be retried, otherwise False. 417 418 </pre> 419 <dl class="fields"> 420 </dl> 421 </td></tr></table> 422 </div> 423 <a name="_retry_request"></a> 424 <div class="private"> 425 <table class="details" border="1" cellpadding="3" 426 cellspacing="0" width="100%" bgcolor="white"> 427 <tr><td> 428 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 429 <tr valign="top"><td> 430 <h3 class="epydoc"><span class="sig"><span class="sig-name">_retry_request</span>(<span class="sig-arg">http</span>, 431 <span class="sig-arg">num_retries</span>, 432 <span class="sig-arg">req_type</span>, 433 <span class="sig-arg">sleep</span>, 434 <span class="sig-arg">rand</span>, 435 <span class="sig-arg">uri</span>, 436 <span class="sig-arg">method</span>, 437 <span class="sig-arg">*args</span>, 438 <span class="sig-arg">**kwargs</span>)</span> 439 </h3> 440 </td><td align="right" valign="top" 441 ><span class="codelink"><a href="googleapiclient.http-pysrc.html#_retry_request">source code</a></span> 442 </td> 443 </tr></table> 444 445 <pre class="literalblock"> 446 Retries an HTTP request multiple times while handling errors. 447 448 If after all retries the request still fails, last error is either returned as 449 return value (for HTTP 5xx errors) or thrown (for ssl.SSLError). 450 451 Args: 452 http: Http object to be used to execute request. 453 num_retries: Maximum number of retries. 454 req_type: Type of the request (used for logging retries). 455 sleep, rand: Functions to sleep for random time between retries. 456 uri: URI to be requested. 457 method: HTTP method to be used. 458 args, kwargs: Additional arguments passed to http.request. 459 460 Returns: 461 resp, content - Response from the http request (may be HTTP 5xx). 462 463 </pre> 464 <dl class="fields"> 465 </dl> 466 </td></tr></table> 467 </div> 468 <a name="set_user_agent"></a> 469 <div> 470 <table class="details" border="1" cellpadding="3" 471 cellspacing="0" width="100%" bgcolor="white"> 472 <tr><td> 473 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 474 <tr valign="top"><td> 475 <h3 class="epydoc"><span class="sig"><span class="sig-name">set_user_agent</span>(<span class="sig-arg">http</span>, 476 <span class="sig-arg">user_agent</span>)</span> 477 </h3> 478 </td><td align="right" valign="top" 479 ><span class="codelink"><a href="googleapiclient.http-pysrc.html#set_user_agent">source code</a></span> 480 </td> 481 </tr></table> 482 483 <pre class="literalblock"> 484 Set the user-agent on every request. 485 486 Args: 487 http - An instance of httplib2.Http 488 or something that acts like it. 489 user_agent: string, the value for the user-agent header. 490 491 Returns: 492 A modified instance of http that was passed in. 493 494 Example: 495 496 h = httplib2.Http() 497 h = set_user_agent(h, "my-app-name/6.0") 498 499 Most of the time the user-agent will be set doing auth, this is for the rare 500 cases where you are accessing an unauthenticated endpoint. 501 502 </pre> 503 <dl class="fields"> 504 </dl> 505 </td></tr></table> 506 </div> 507 <a name="tunnel_patch"></a> 508 <div> 509 <table class="details" border="1" cellpadding="3" 510 cellspacing="0" width="100%" bgcolor="white"> 511 <tr><td> 512 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 513 <tr valign="top"><td> 514 <h3 class="epydoc"><span class="sig"><span class="sig-name">tunnel_patch</span>(<span class="sig-arg">http</span>)</span> 515 </h3> 516 </td><td align="right" valign="top" 517 ><span class="codelink"><a href="googleapiclient.http-pysrc.html#tunnel_patch">source code</a></span> 518 </td> 519 </tr></table> 520 521 <pre class="literalblock"> 522 Tunnel PATCH requests over POST. 523 Args: 524 http - An instance of httplib2.Http 525 or something that acts like it. 526 527 Returns: 528 A modified instance of http that was passed in. 529 530 Example: 531 532 h = httplib2.Http() 533 h = tunnel_patch(h, "my-app-name/6.0") 534 535 Useful if you are running on a platform that doesn't support PATCH. 536 Apply this last if you are using OAuth 1.0, as changing the method 537 will result in a different signature. 538 539 </pre> 540 <dl class="fields"> 541 </dl> 542 </td></tr></table> 543 </div> 544 <a name="build_http"></a> 545 <div> 546 <table class="details" border="1" cellpadding="3" 547 cellspacing="0" width="100%" bgcolor="white"> 548 <tr><td> 549 <table width="100%" cellpadding="0" cellspacing="0" border="0"> 550 <tr valign="top"><td> 551 <h3 class="epydoc"><span class="sig"><span class="sig-name">build_http</span>()</span> 552 </h3> 553 </td><td align="right" valign="top" 554 ><span class="codelink"><a href="googleapiclient.http-pysrc.html#build_http">source code</a></span> 555 </td> 556 </tr></table> 557 558 <pre class="literalblock"> 559 Builds httplib2.Http object 560 561 Returns: 562 A httplib2.Http object, which is used to make http requests, and which has timeout set by default. 563 To override default timeout call 564 565 socket.setdefaulttimeout(timeout_in_sec) 566 567 before interacting with this method. 568 569 </pre> 570 <dl class="fields"> 571 </dl> 572 </td></tr></table> 573 </div> 574 <br /> 575 <!-- ==================== NAVIGATION BAR ==================== --> 576 <table class="navbar" border="0" width="100%" cellpadding="0" 577 bgcolor="#a0c0ff" cellspacing="0"> 578 <tr valign="middle"> 579 <!-- Home link --> 580 <th> <a 581 href="googleapiclient-module.html">Home</a> </th> 582 583 <!-- Tree link --> 584 <th> <a 585 href="module-tree.html">Trees</a> </th> 586 587 <!-- Index link --> 588 <th> <a 589 href="identifier-index.html">Indices</a> </th> 590 591 <!-- Help link --> 592 <th> <a 593 href="help.html">Help</a> </th> 594 595 <th class="navbar" width="100%"></th> 596 </tr> 597 </table> 598 <table border="0" cellpadding="0" cellspacing="0" width="100%%"> 599 <tr> 600 <td align="left" class="footer"> 601 Generated by Epydoc 3.0.1 on Mon Jun 5 13:38:39 2017 602 </td> 603 <td align="right" class="footer"> 604 <a target="mainFrame" href="http://epydoc.sourceforge.net" 605 >http://epydoc.sourceforge.net</a> 606 </td> 607 </tr> 608 </table> 609 610 <script type="text/javascript"> 611 <!-- 612 // Private objects are initially displayed (because if 613 // javascript is turned off then we want them to be 614 // visible); but by default, we want to hide them. So hide 615 // them unless we have a cookie that says to show them. 616 checkCookie(); 617 // --> 618 </script> 619 </body> 620 </html> 621