• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.HttpRequest</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>&nbsp;&nbsp;&nbsp;<a
19        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21  <!-- Tree link -->
22      <th>&nbsp;&nbsp;&nbsp;<a
23        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25  <!-- Index link -->
26      <th>&nbsp;&nbsp;&nbsp;<a
27        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29  <!-- Help link -->
30      <th>&nbsp;&nbsp;&nbsp;<a
31        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</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&nbsp;googleapiclient</a> ::
41        <a href="googleapiclient.http-module.html">Module&nbsp;http</a> ::
42        Class&nbsp;HttpRequest
43      </span>
44    </td>
45    <td>
46      <table cellpadding="0" cellspacing="0">
47        <!-- hide/show private -->
48        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
49    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
50        <tr><td align="right"><span class="options"
51            >[<a href="frames.html" target="_top">frames</a
52            >]&nbsp;|&nbsp;<a href="googleapiclient.http.HttpRequest-class.html"
53            target="_top">no&nbsp;frames</a>]</span></td></tr>
54      </table>
55    </td>
56  </tr>
57</table>
58<!-- ==================== CLASS DESCRIPTION ==================== -->
59<h1 class="epydoc">Class HttpRequest</h1><p class="nomargin-top"><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest">source&nbsp;code</a></span></p>
60<center>
61
62</center>
63<hr />
64<pre class="literalblock">
65Encapsulates a single HTTP request.
66
67</pre>
68
69<!-- ==================== INSTANCE METHODS ==================== -->
70<a name="section-InstanceMethods"></a>
71<table class="summary" border="1" cellpadding="3"
72       cellspacing="0" width="100%" bgcolor="white">
73<tr bgcolor="#70b0f0" class="table-header">
74  <td colspan="2" class="table-header">
75    <table border="0" cellpadding="0" cellspacing="0" width="100%">
76      <tr valign="top">
77        <td align="left"><span class="table-header">Instance Methods</span></td>
78        <td align="right" valign="top"
79         ><span class="options">[<a href="#section-InstanceMethods"
80         class="privatelink" onclick="toggle_private();"
81         >hide private</a>]</span></td>
82      </tr>
83    </table>
84  </td>
85</tr>
86<tr>
87    <td width="15%" align="right" valign="top" class="summary">
88      <span class="summary-type">&nbsp;</span>
89    </td><td class="summary">
90      <table width="100%" cellpadding="0" cellspacing="0" border="0">
91        <tr>
92          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
93        <span class="summary-sig-arg">http</span>,
94        <span class="summary-sig-arg">postproc</span>,
95        <span class="summary-sig-arg">uri</span>,
96        <span class="summary-sig-arg">method</span>=<span class="summary-sig-default">'GET'</span>,
97        <span class="summary-sig-arg">body</span>=<span class="summary-sig-default">None</span>,
98        <span class="summary-sig-arg">headers</span>=<span class="summary-sig-default">None</span>,
99        <span class="summary-sig-arg">methodId</span>=<span class="summary-sig-default">None</span>,
100        <span class="summary-sig-arg">resumable</span>=<span class="summary-sig-default">None</span>)</span><br />
101      Constructor for an HttpRequest.</td>
102          <td align="right" valign="top">
103            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.__init__">source&nbsp;code</a></span>
104
105          </td>
106        </tr>
107      </table>
108
109    </td>
110  </tr>
111<tr>
112    <td width="15%" align="right" valign="top" class="summary">
113      <span class="summary-type">&nbsp;</span>
114    </td><td class="summary">
115      <table width="100%" cellpadding="0" cellspacing="0" border="0">
116        <tr>
117          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#execute" class="summary-sig-name">execute</a>(<span class="summary-sig-arg">self</span>,
118        <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>,
119        <span class="summary-sig-arg">num_retries</span>=<span class="summary-sig-default">0</span>)</span><br />
120      Execute the request.</td>
121          <td align="right" valign="top">
122            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.execute">source&nbsp;code</a></span>
123
124          </td>
125        </tr>
126      </table>
127
128    </td>
129  </tr>
130<tr>
131    <td width="15%" align="right" valign="top" class="summary">
132      <span class="summary-type">&nbsp;</span>
133    </td><td class="summary">
134      <table width="100%" cellpadding="0" cellspacing="0" border="0">
135        <tr>
136          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#add_response_callback" class="summary-sig-name">add_response_callback</a>(<span class="summary-sig-arg">self</span>,
137        <span class="summary-sig-arg">cb</span>)</span><br />
138      add_response_headers_callback</td>
139          <td align="right" valign="top">
140            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.add_response_callback">source&nbsp;code</a></span>
141
142          </td>
143        </tr>
144      </table>
145
146    </td>
147  </tr>
148<tr>
149    <td width="15%" align="right" valign="top" class="summary">
150      <span class="summary-type">&nbsp;</span>
151    </td><td class="summary">
152      <table width="100%" cellpadding="0" cellspacing="0" border="0">
153        <tr>
154          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#next_chunk" class="summary-sig-name">next_chunk</a>(<span class="summary-sig-arg">self</span>,
155        <span class="summary-sig-arg">http</span>=<span class="summary-sig-default">None</span>,
156        <span class="summary-sig-arg">num_retries</span>=<span class="summary-sig-default">0</span>)</span><br />
157      Execute the next step of a resumable upload.</td>
158          <td align="right" valign="top">
159            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.next_chunk">source&nbsp;code</a></span>
160
161          </td>
162        </tr>
163      </table>
164
165    </td>
166  </tr>
167<tr class="private">
168    <td width="15%" align="right" valign="top" class="summary">
169      <span class="summary-type">&nbsp;</span>
170    </td><td class="summary">
171      <table width="100%" cellpadding="0" cellspacing="0" border="0">
172        <tr>
173          <td><span class="summary-sig"><a href="googleapiclient.http.HttpRequest-class.html#_process_response" class="summary-sig-name" onclick="show_private();">_process_response</a>(<span class="summary-sig-arg">self</span>,
174        <span class="summary-sig-arg">resp</span>,
175        <span class="summary-sig-arg">content</span>)</span><br />
176      Process the response from a single chunk upload.</td>
177          <td align="right" valign="top">
178            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest._process_response">source&nbsp;code</a></span>
179
180          </td>
181        </tr>
182      </table>
183
184    </td>
185  </tr>
186<tr>
187    <td width="15%" align="right" valign="top" class="summary">
188      <span class="summary-type">&nbsp;</span>
189    </td><td class="summary">
190      <table width="100%" cellpadding="0" cellspacing="0" border="0">
191        <tr>
192          <td><span class="summary-sig"><a name="to_json"></a><span class="summary-sig-name">to_json</span>(<span class="summary-sig-arg">self</span>)</span><br />
193      Returns a JSON representation of the HttpRequest.</td>
194          <td align="right" valign="top">
195            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.to_json">source&nbsp;code</a></span>
196
197          </td>
198        </tr>
199      </table>
200
201    </td>
202  </tr>
203  <tr>
204    <td colspan="2" class="summary">
205    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
206      <code>__delattr__</code>,
207      <code>__format__</code>,
208      <code>__getattribute__</code>,
209      <code>__hash__</code>,
210      <code>__new__</code>,
211      <code>__reduce__</code>,
212      <code>__reduce_ex__</code>,
213      <code>__repr__</code>,
214      <code>__setattr__</code>,
215      <code>__sizeof__</code>,
216      <code>__str__</code>,
217      <code>__subclasshook__</code>
218      </p>
219    </td>
220  </tr>
221</table>
222<!-- ==================== STATIC METHODS ==================== -->
223<a name="section-StaticMethods"></a>
224<table class="summary" border="1" cellpadding="3"
225       cellspacing="0" width="100%" bgcolor="white">
226<tr bgcolor="#70b0f0" class="table-header">
227  <td colspan="2" class="table-header">
228    <table border="0" cellpadding="0" cellspacing="0" width="100%">
229      <tr valign="top">
230        <td align="left"><span class="table-header">Static Methods</span></td>
231        <td align="right" valign="top"
232         ><span class="options">[<a href="#section-StaticMethods"
233         class="privatelink" onclick="toggle_private();"
234         >hide private</a>]</span></td>
235      </tr>
236    </table>
237  </td>
238</tr>
239<tr>
240    <td width="15%" align="right" valign="top" class="summary">
241      <span class="summary-type">&nbsp;</span>
242    </td><td class="summary">
243      <table width="100%" cellpadding="0" cellspacing="0" border="0">
244        <tr>
245          <td><span class="summary-sig"><a name="from_json"></a><span class="summary-sig-name">from_json</span>(<span class="summary-sig-arg">s</span>,
246        <span class="summary-sig-arg">http</span>,
247        <span class="summary-sig-arg">postproc</span>)</span><br />
248      Returns an HttpRequest populated with info from a JSON object.</td>
249          <td align="right" valign="top">
250            <span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.from_json">source&nbsp;code</a></span>
251
252          </td>
253        </tr>
254      </table>
255
256    </td>
257  </tr>
258</table>
259<!-- ==================== PROPERTIES ==================== -->
260<a name="section-Properties"></a>
261<table class="summary" border="1" cellpadding="3"
262       cellspacing="0" width="100%" bgcolor="white">
263<tr bgcolor="#70b0f0" class="table-header">
264  <td colspan="2" class="table-header">
265    <table border="0" cellpadding="0" cellspacing="0" width="100%">
266      <tr valign="top">
267        <td align="left"><span class="table-header">Properties</span></td>
268        <td align="right" valign="top"
269         ><span class="options">[<a href="#section-Properties"
270         class="privatelink" onclick="toggle_private();"
271         >hide private</a>]</span></td>
272      </tr>
273    </table>
274  </td>
275</tr>
276  <tr>
277    <td colspan="2" class="summary">
278    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
279      <code>__class__</code>
280      </p>
281    </td>
282  </tr>
283</table>
284<!-- ==================== METHOD DETAILS ==================== -->
285<a name="section-MethodDetails"></a>
286<table class="details" border="1" cellpadding="3"
287       cellspacing="0" width="100%" bgcolor="white">
288<tr bgcolor="#70b0f0" class="table-header">
289  <td colspan="2" class="table-header">
290    <table border="0" cellpadding="0" cellspacing="0" width="100%">
291      <tr valign="top">
292        <td align="left"><span class="table-header">Method Details</span></td>
293        <td align="right" valign="top"
294         ><span class="options">[<a href="#section-MethodDetails"
295         class="privatelink" onclick="toggle_private();"
296         >hide private</a>]</span></td>
297      </tr>
298    </table>
299  </td>
300</tr>
301</table>
302<a name="__init__"></a>
303<div>
304<table class="details" border="1" cellpadding="3"
305       cellspacing="0" width="100%" bgcolor="white">
306<tr><td>
307  <table width="100%" cellpadding="0" cellspacing="0" border="0">
308  <tr valign="top"><td>
309  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
310        <span class="sig-arg">http</span>,
311        <span class="sig-arg">postproc</span>,
312        <span class="sig-arg">uri</span>,
313        <span class="sig-arg">method</span>=<span class="sig-default">'GET'</span>,
314        <span class="sig-arg">body</span>=<span class="sig-default">None</span>,
315        <span class="sig-arg">headers</span>=<span class="sig-default">None</span>,
316        <span class="sig-arg">methodId</span>=<span class="sig-default">None</span>,
317        <span class="sig-arg">resumable</span>=<span class="sig-default">None</span>)</span>
318    <br /><em class="fname">(Constructor)</em>
319  </h3>
320  </td><td align="right" valign="top"
321    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.__init__">source&nbsp;code</a></span>&nbsp;
322    </td>
323  </tr></table>
324
325  <pre class="literalblock">
326Constructor for an HttpRequest.
327
328Args:
329  http: httplib2.Http, the transport object to use to make a request
330  postproc: callable, called on the HTTP response and content to transform
331            it into a data object before returning, or raising an exception
332            on an error.
333  uri: string, the absolute URI to send the request to
334  method: string, the HTTP method to use
335  body: string, the request body of the HTTP request,
336  headers: dict, the HTTP request headers
337  methodId: string, a unique identifier for the API method being called.
338  resumable: MediaUpload, None if this is not a resumbale request.
339
340</pre>
341  <dl class="fields">
342    <dt>Decorators:</dt>
343    <dd><ul class="nomargin-top">
344        <li><code>@util.positional(4)</code></li>
345    </ul></dd>
346    <dt>Overrides:
347        object.__init__
348    </dt>
349  </dl>
350</td></tr></table>
351</div>
352<a name="execute"></a>
353<div>
354<table class="details" border="1" cellpadding="3"
355       cellspacing="0" width="100%" bgcolor="white">
356<tr><td>
357  <table width="100%" cellpadding="0" cellspacing="0" border="0">
358  <tr valign="top"><td>
359  <h3 class="epydoc"><span class="sig"><span class="sig-name">execute</span>(<span class="sig-arg">self</span>,
360        <span class="sig-arg">http</span>=<span class="sig-default">None</span>,
361        <span class="sig-arg">num_retries</span>=<span class="sig-default">0</span>)</span>
362  </h3>
363  </td><td align="right" valign="top"
364    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.execute">source&nbsp;code</a></span>&nbsp;
365    </td>
366  </tr></table>
367
368  <pre class="literalblock">
369Execute the request.
370
371Args:
372  http: httplib2.Http, an http object to be used in place of the
373        one the HttpRequest request object was constructed with.
374  num_retries: Integer, number of times to retry with randomized
375        exponential backoff. If all retries fail, the raised HttpError
376        represents the last request. If zero (default), we attempt the
377        request only once.
378
379Returns:
380  A deserialized object model of the response body as determined
381  by the postproc.
382
383Raises:
384  googleapiclient.errors.HttpError if the response was not a 2xx.
385  httplib2.HttpLib2Error if a transport error has occured.
386
387</pre>
388  <dl class="fields">
389    <dt>Decorators:</dt>
390    <dd><ul class="nomargin-top">
391        <li><code>@util.positional(1)</code></li>
392    </ul></dd>
393  </dl>
394</td></tr></table>
395</div>
396<a name="add_response_callback"></a>
397<div>
398<table class="details" border="1" cellpadding="3"
399       cellspacing="0" width="100%" bgcolor="white">
400<tr><td>
401  <table width="100%" cellpadding="0" cellspacing="0" border="0">
402  <tr valign="top"><td>
403  <h3 class="epydoc"><span class="sig"><span class="sig-name">add_response_callback</span>(<span class="sig-arg">self</span>,
404        <span class="sig-arg">cb</span>)</span>
405  </h3>
406  </td><td align="right" valign="top"
407    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.add_response_callback">source&nbsp;code</a></span>&nbsp;
408    </td>
409  </tr></table>
410
411  <pre class="literalblock">
412add_response_headers_callback
413
414Args:
415  cb: Callback to be called on receiving the response headers, of signature:
416
417  def cb(resp):
418    # Where resp is an instance of httplib2.Response
419
420</pre>
421  <dl class="fields">
422    <dt>Decorators:</dt>
423    <dd><ul class="nomargin-top">
424        <li><code>@util.positional(2)</code></li>
425    </ul></dd>
426  </dl>
427</td></tr></table>
428</div>
429<a name="next_chunk"></a>
430<div>
431<table class="details" border="1" cellpadding="3"
432       cellspacing="0" width="100%" bgcolor="white">
433<tr><td>
434  <table width="100%" cellpadding="0" cellspacing="0" border="0">
435  <tr valign="top"><td>
436  <h3 class="epydoc"><span class="sig"><span class="sig-name">next_chunk</span>(<span class="sig-arg">self</span>,
437        <span class="sig-arg">http</span>=<span class="sig-default">None</span>,
438        <span class="sig-arg">num_retries</span>=<span class="sig-default">0</span>)</span>
439  </h3>
440  </td><td align="right" valign="top"
441    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest.next_chunk">source&nbsp;code</a></span>&nbsp;
442    </td>
443  </tr></table>
444
445  <pre class="literalblock">
446Execute the next step of a resumable upload.
447
448Can only be used if the method being executed supports media uploads and
449the MediaUpload object passed in was flagged as using resumable upload.
450
451Example:
452
453  media = MediaFileUpload('cow.png', mimetype='image/png',
454                          chunksize=1000, resumable=True)
455  request = farm.animals().insert(
456      id='cow',
457      name='cow.png',
458      media_body=media)
459
460  response = None
461  while response is None:
462    status, response = request.next_chunk()
463    if status:
464      print &quot;Upload %d%% complete.&quot; % int(status.progress() * 100)
465
466
467Args:
468  http: httplib2.Http, an http object to be used in place of the
469        one the HttpRequest request object was constructed with.
470  num_retries: Integer, number of times to retry with randomized
471        exponential backoff. If all retries fail, the raised HttpError
472        represents the last request. If zero (default), we attempt the
473        request only once.
474
475Returns:
476  (status, body): (ResumableMediaStatus, object)
477     The body will be None until the resumable media is fully uploaded.
478
479Raises:
480  googleapiclient.errors.HttpError if the response was not a 2xx.
481  httplib2.HttpLib2Error if a transport error has occured.
482
483</pre>
484  <dl class="fields">
485    <dt>Decorators:</dt>
486    <dd><ul class="nomargin-top">
487        <li><code>@util.positional(1)</code></li>
488    </ul></dd>
489  </dl>
490</td></tr></table>
491</div>
492<a name="_process_response"></a>
493<div class="private">
494<table class="details" border="1" cellpadding="3"
495       cellspacing="0" width="100%" bgcolor="white">
496<tr><td>
497  <table width="100%" cellpadding="0" cellspacing="0" border="0">
498  <tr valign="top"><td>
499  <h3 class="epydoc"><span class="sig"><span class="sig-name">_process_response</span>(<span class="sig-arg">self</span>,
500        <span class="sig-arg">resp</span>,
501        <span class="sig-arg">content</span>)</span>
502  </h3>
503  </td><td align="right" valign="top"
504    ><span class="codelink"><a href="googleapiclient.http-pysrc.html#HttpRequest._process_response">source&nbsp;code</a></span>&nbsp;
505    </td>
506  </tr></table>
507
508  <pre class="literalblock">
509Process the response from a single chunk upload.
510
511Args:
512  resp: httplib2.Response, the response object.
513  content: string, the content of the response.
514
515Returns:
516  (status, body): (ResumableMediaStatus, object)
517     The body will be None until the resumable media is fully uploaded.
518
519Raises:
520  googleapiclient.errors.HttpError if the response was not a 2xx or a 308.
521
522</pre>
523  <dl class="fields">
524  </dl>
525</td></tr></table>
526</div>
527<br />
528<!-- ==================== NAVIGATION BAR ==================== -->
529<table class="navbar" border="0" width="100%" cellpadding="0"
530       bgcolor="#a0c0ff" cellspacing="0">
531  <tr valign="middle">
532  <!-- Home link -->
533      <th>&nbsp;&nbsp;&nbsp;<a
534        href="googleapiclient-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
535
536  <!-- Tree link -->
537      <th>&nbsp;&nbsp;&nbsp;<a
538        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
539
540  <!-- Index link -->
541      <th>&nbsp;&nbsp;&nbsp;<a
542        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
543
544  <!-- Help link -->
545      <th>&nbsp;&nbsp;&nbsp;<a
546        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
547
548      <th class="navbar" width="100%"></th>
549  </tr>
550</table>
551<table border="0" cellpadding="0" cellspacing="0" width="100%%">
552  <tr>
553    <td align="left" class="footer">
554    Generated by Epydoc 3.0.1 on Mon Jun  5 13:38:40 2017
555    </td>
556    <td align="right" class="footer">
557      <a target="mainFrame" href="http://epydoc.sourceforge.net"
558        >http://epydoc.sourceforge.net</a>
559    </td>
560  </tr>
561</table>
562
563<script type="text/javascript">
564  <!--
565  // Private objects are initially displayed (because if
566  // javascript is turned off then we want them to be
567  // visible); but by default, we want to hide them.  So hide
568  // them unless we have a cookie that says to show them.
569  checkCookie();
570  // -->
571</script>
572</body>
573</html>
574