blob: 0b78a1632ec381af5a97edcec4fe7a72d9666b04 [file] [log] [blame]
jcgregorio26c0cd72006-07-03 17:36:17 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="ref.css" type='text/css' />
5<link rel="first" href="ref.html" title='The httplib2 Library' />
6<link rel='contents' href='contents.html' title="Contents" />
7<link rel='last' href='about.html' title='About this document...' />
8<link rel='help' href='about.html' title='About this document...' />
9<link rel="next" href="httplib2-example.html" />
10<link rel="prev" href="cache-objects.html" />
11<link rel="parent" href="module-httplib2.html" />
12<link rel="next" href="httplib2-example.html" />
13<meta name='aesop' content='information' />
14<title>1.1.3 Response Objects</title>
15</head>
16<body>
17<DIV CLASS="navigation">
18<div id='top-navigation-panel' xml:id='top-navigation-panel'>
19<table align="center" width="100%" cellpadding="0" cellspacing="2">
20<tr>
21<td class='online-navigation'><a rel="prev" title="1.1.2 Cache Objects"
22 href="cache-objects.html"><img src='previous.png'
23 border='0' height='32' alt='Previous Page' width='32' /></A></td>
24<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive"
25 href="module-httplib2.html"><img src='up.png'
26 border='0' height='32' alt='Up One Level' width='32' /></A></td>
27<td class='online-navigation'><a rel="next" title="1.1.4 Examples"
28 href="httplib2-example.html"><img src='next.png'
29 border='0' height='32' alt='Next Page' width='32' /></A></td>
30<td align="center" width="100%">The httplib2 Library</td>
31<td class='online-navigation'><a rel="contents" title="Table of Contents"
32 href="contents.html"><img src='contents.png'
33 border='0' height='32' alt='Contents' width='32' /></A></td>
34<td class='online-navigation'><img src='blank.png'
35 border='0' height='32' alt='' width='32' /></td>
36<td class='online-navigation'><img src='blank.png'
37 border='0' height='32' alt='' width='32' /></td>
38</tr></table>
39<div class='online-navigation'>
40<b class="navlabel">Previous:</b>
41<a class="sectref" rel="prev" href="cache-objects.html">1.1.2 Cache Objects</A>
42<b class="navlabel">Up:</b>
43<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
44<b class="navlabel">Next:</b>
45<a class="sectref" rel="next" href="httplib2-example.html">1.1.4 Examples</A>
46</div>
47<hr /></div>
48</DIV>
49<!--End of Navigation Panel-->
50
51<H2><A NAME="SECTION002130000000000000000"></A>
52<A NAME="response-objects"></A>
53<BR>
541.1.3 Response Objects
55</H2>
56
57<P>
58Response objects are derived from <tt class="class">dict</tt> and map
59header names (lower case with the trailing colon removed)
60to header values. In addition to the dict methods
61a Response object also has:
62
63<P>
jcgregoriocde4f092007-03-08 21:59:04 +000064<dl><dt><b><tt id='l2h-23' xml:id='l2h-23' class="member">fromcache</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +000065<dd>
66If <code>true</code> the the response was returned from the cache.
67</dl>
68
69<P>
jcgregoriocde4f092007-03-08 21:59:04 +000070<dl><dt><b><tt id='l2h-24' xml:id='l2h-24' class="member">version</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +000071<dd>
72The version of HTTP that the server supports. A value
73of 11 means '1.1'.
74</dl>
75
76<P>
jcgregoriocde4f092007-03-08 21:59:04 +000077<dl><dt><b><tt id='l2h-25' xml:id='l2h-25' class="member">status</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +000078<dd>
79The numerical HTTP status code returned in the response.
80</dl>
81
82<P>
jcgregoriocde4f092007-03-08 21:59:04 +000083<dl><dt><b><tt id='l2h-26' xml:id='l2h-26' class="member">reason</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +000084<dd>
85The human readable component of the HTTP response status code.
86</dl>
87
88<P>
jcgregoriocde4f092007-03-08 21:59:04 +000089<dl><dt><b><tt id='l2h-27' xml:id='l2h-27' class="member">previous</tt></b></dt>
jcgregorio26c0cd72006-07-03 17:36:17 +000090<dd>
91If redirects are followed then the <tt class="class">Response</tt> object returned
92is just for the very last HTTP request and <var>previous</var> points to
93the previous <tt class="class">Response</tt> object. In this manner they form a chain
94going back through the responses to the very first response.
95Will be <code>None</code> if there are no previous respones.
96</dl>
97
98<P>
jcgregorio772adc82006-11-17 21:52:34 +000099The Response object also populates the header <code>content-location</code>, that
jcgregoriof76c9512006-11-07 18:01:50 +0000100contains the URI that was ultimately requested. This is useful if
101redirects were encountered, you can determine the ultimate URI that
102the request was sent to. All Response objects contain this key value,
103including <code>previous</code> responses so you can determine the entire
jcgregoriocde4f092007-03-08 21:59:04 +0000104chain of redirects. If <tt class="member">Http.force_exception_to_status_code</tt> is <code>True</code>
105and the number of redirects has exceeded the number of allowed number
106of redirects then the <tt class="class">Response</tt> object will report the error
107in the status code, but the complete chain of previous responses will
108still be in tact.
jcgregoriof76c9512006-11-07 18:01:50 +0000109
110<P>
jcgregorio26c0cd72006-07-03 17:36:17 +0000111
112<DIV CLASS="navigation">
113<div class='online-navigation'>
114<p></p><hr />
115<table align="center" width="100%" cellpadding="0" cellspacing="2">
116<tr>
117<td class='online-navigation'><a rel="prev" title="1.1.2 Cache Objects"
118 href="cache-objects.html"><img src='previous.png'
119 border='0' height='32' alt='Previous Page' width='32' /></A></td>
120<td class='online-navigation'><a rel="parent" title="1.1 httplib2 A comprehensive"
121 href="module-httplib2.html"><img src='up.png'
122 border='0' height='32' alt='Up One Level' width='32' /></A></td>
123<td class='online-navigation'><a rel="next" title="1.1.4 Examples"
124 href="httplib2-example.html"><img src='next.png'
125 border='0' height='32' alt='Next Page' width='32' /></A></td>
126<td align="center" width="100%">The httplib2 Library</td>
127<td class='online-navigation'><a rel="contents" title="Table of Contents"
128 href="contents.html"><img src='contents.png'
129 border='0' height='32' alt='Contents' width='32' /></A></td>
130<td class='online-navigation'><img src='blank.png'
131 border='0' height='32' alt='' width='32' /></td>
132<td class='online-navigation'><img src='blank.png'
133 border='0' height='32' alt='' width='32' /></td>
134</tr></table>
135<div class='online-navigation'>
136<b class="navlabel">Previous:</b>
137<a class="sectref" rel="prev" href="cache-objects.html">1.1.2 Cache Objects</A>
138<b class="navlabel">Up:</b>
139<a class="sectref" rel="parent" href="module-httplib2.html">1.1 httplib2 A comprehensive</A>
140<b class="navlabel">Next:</b>
141<a class="sectref" rel="next" href="httplib2-example.html">1.1.4 Examples</A>
142</div>
143</div>
144<hr />
jcgregoriocde4f092007-03-08 21:59:04 +0000145<span class="release-info">Release 0.3, documentation updated on Mar 8, 2007.</span>
jcgregorio26c0cd72006-07-03 17:36:17 +0000146</DIV>
147<!--End of Navigation Panel-->
148
149</BODY>
150</HTML>