Show More
@@ -255,7 +255,217 b' files, or words in the commit message</d' | |||||
255 | <th class="annotate">rev</th> |
|
255 | <th class="annotate">rev</th> | |
256 | <th class="line"> line source</th> |
|
256 | <th class="line"> line source</th> | |
257 | </tr> |
|
257 | </tr> | |
258 | <tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#1" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#2" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l2" id="l2"> 2</a> </td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#3" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l3" id="l3"> 3</a> <span class="n">__doc__</span> <span class="o">=</span> <span class="s">"""This does HTTP get requests given a host:port and path and returns</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#4" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l4" id="l4"> 4</a> <span class="s">a subset of the headers plus the body of the result."""</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#5" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l5" id="l5"> 5</a> </td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#6" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l6" id="l6"> 6</a> <span class="kn">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">re</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#7" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l7" id="l7"> 7</a> </td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#8" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l8" id="l8"> 8</a> <span class="kn">try</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#9" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l9" id="l9"> 9</a> <span class="kn">import</span> <span class="nn">msvcrt</span><span class="o">,</span> <span class="nn">os</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#10" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l10" id="l10"> 10</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#11" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l11" id="l11"> 11</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#12" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l12" id="l12"> 12</a> <span class="kn">except</span> <span class="ne">ImportError</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#13" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l13" id="l13"> 13</a> <span class="kn">pass</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#14" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l14" id="l14"> 14</a> </td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#15" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l15" id="l15"> 15</a> <span class="n">headers</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">3</span><span class="p">:]]</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#16" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l16" id="l16"> 16</a> <span class="n">conn</span> <span class="o">=</span> <span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#17" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l17" id="l17"> 17</a> <span class="n">conn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">"GET"</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">2</span><span class="p">])</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#18" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l18" id="l18"> 18</a> <span class="n">response</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#19" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l19" id="l19"> 19</a> <span class="kn">print</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">reason</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#20" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#21" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l21" id="l21"> 21</a> <span class="kn">if</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#22" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l22" id="l22"> 22</a> <span class="kn">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">))</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#23" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l23" id="l23"> 23</a> <span class="kn">print</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#24" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l24" id="l24"> 24</a> <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">()</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#25" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l25" id="l25"> 25</a> <span class="n">data</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">'\d+ years'</span><span class="p">,</span> <span class="s">'many years'</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#26" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l26" id="l26"> 26</a> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#27" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l27" id="l27"> 27</a> </td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#28" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l28" id="l28"> 28</a> <span class="kn">if</span> <span class="mf">200</span> <span class="o"><=</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o"><=</span> <span class="mf">299</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#29" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l29" id="l29"> 29</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">0</span><span class="p">)</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#30" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l30" id="l30"> 30</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></td></tr> |
|
258 | ||
|
259 | <tr class="parity0"> | |||
|
260 | <td class="annotate"> | |||
|
261 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#1" | |||
|
262 | title="7c3facd7c58a: a">test@0</a> | |||
|
263 | </td> | |||
|
264 | <td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td> | |||
|
265 | </tr> | |||
|
266 | <tr class="parity1"> | |||
|
267 | <td class="annotate"> | |||
|
268 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#2" | |||
|
269 | title="7c3facd7c58a: a">test@0</a> | |||
|
270 | </td> | |||
|
271 | <td class="source"><a href="#l2" id="l2"> 2</a> </td> | |||
|
272 | </tr> | |||
|
273 | <tr class="parity0"> | |||
|
274 | <td class="annotate"> | |||
|
275 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#3" | |||
|
276 | title="7c3facd7c58a: a">test@0</a> | |||
|
277 | </td> | |||
|
278 | <td class="source"><a href="#l3" id="l3"> 3</a> <span class="n">__doc__</span> <span class="o">=</span> <span class="s">"""This does HTTP get requests given a host:port and path and returns</span></td> | |||
|
279 | </tr> | |||
|
280 | <tr class="parity1"> | |||
|
281 | <td class="annotate"> | |||
|
282 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#4" | |||
|
283 | title="7c3facd7c58a: a">test@0</a> | |||
|
284 | </td> | |||
|
285 | <td class="source"><a href="#l4" id="l4"> 4</a> <span class="s">a subset of the headers plus the body of the result."""</span></td> | |||
|
286 | </tr> | |||
|
287 | <tr class="parity0"> | |||
|
288 | <td class="annotate"> | |||
|
289 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#5" | |||
|
290 | title="7c3facd7c58a: a">test@0</a> | |||
|
291 | </td> | |||
|
292 | <td class="source"><a href="#l5" id="l5"> 5</a> </td> | |||
|
293 | </tr> | |||
|
294 | <tr class="parity1"> | |||
|
295 | <td class="annotate"> | |||
|
296 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#6" | |||
|
297 | title="7c3facd7c58a: a">test@0</a> | |||
|
298 | </td> | |||
|
299 | <td class="source"><a href="#l6" id="l6"> 6</a> <span class="kn">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">re</span></td> | |||
|
300 | </tr> | |||
|
301 | <tr class="parity0"> | |||
|
302 | <td class="annotate"> | |||
|
303 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#7" | |||
|
304 | title="7c3facd7c58a: a">test@0</a> | |||
|
305 | </td> | |||
|
306 | <td class="source"><a href="#l7" id="l7"> 7</a> </td> | |||
|
307 | </tr> | |||
|
308 | <tr class="parity1"> | |||
|
309 | <td class="annotate"> | |||
|
310 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#8" | |||
|
311 | title="7c3facd7c58a: a">test@0</a> | |||
|
312 | </td> | |||
|
313 | <td class="source"><a href="#l8" id="l8"> 8</a> <span class="kn">try</span><span class="p">:</span></td> | |||
|
314 | </tr> | |||
|
315 | <tr class="parity0"> | |||
|
316 | <td class="annotate"> | |||
|
317 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#9" | |||
|
318 | title="7c3facd7c58a: a">test@0</a> | |||
|
319 | </td> | |||
|
320 | <td class="source"><a href="#l9" id="l9"> 9</a> <span class="kn">import</span> <span class="nn">msvcrt</span><span class="o">,</span> <span class="nn">os</span></td> | |||
|
321 | </tr> | |||
|
322 | <tr class="parity1"> | |||
|
323 | <td class="annotate"> | |||
|
324 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#10" | |||
|
325 | title="7c3facd7c58a: a">test@0</a> | |||
|
326 | </td> | |||
|
327 | <td class="source"><a href="#l10" id="l10"> 10</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></td> | |||
|
328 | </tr> | |||
|
329 | <tr class="parity0"> | |||
|
330 | <td class="annotate"> | |||
|
331 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#11" | |||
|
332 | title="7c3facd7c58a: a">test@0</a> | |||
|
333 | </td> | |||
|
334 | <td class="source"><a href="#l11" id="l11"> 11</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></td> | |||
|
335 | </tr> | |||
|
336 | <tr class="parity1"> | |||
|
337 | <td class="annotate"> | |||
|
338 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#12" | |||
|
339 | title="7c3facd7c58a: a">test@0</a> | |||
|
340 | </td> | |||
|
341 | <td class="source"><a href="#l12" id="l12"> 12</a> <span class="kn">except</span> <span class="ne">ImportError</span><span class="p">:</span></td> | |||
|
342 | </tr> | |||
|
343 | <tr class="parity0"> | |||
|
344 | <td class="annotate"> | |||
|
345 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#13" | |||
|
346 | title="7c3facd7c58a: a">test@0</a> | |||
|
347 | </td> | |||
|
348 | <td class="source"><a href="#l13" id="l13"> 13</a> <span class="kn">pass</span></td> | |||
|
349 | </tr> | |||
|
350 | <tr class="parity1"> | |||
|
351 | <td class="annotate"> | |||
|
352 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#14" | |||
|
353 | title="7c3facd7c58a: a">test@0</a> | |||
|
354 | </td> | |||
|
355 | <td class="source"><a href="#l14" id="l14"> 14</a> </td> | |||
|
356 | </tr> | |||
|
357 | <tr class="parity0"> | |||
|
358 | <td class="annotate"> | |||
|
359 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#15" | |||
|
360 | title="7c3facd7c58a: a">test@0</a> | |||
|
361 | </td> | |||
|
362 | <td class="source"><a href="#l15" id="l15"> 15</a> <span class="n">headers</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">3</span><span class="p">:]]</span></td> | |||
|
363 | </tr> | |||
|
364 | <tr class="parity1"> | |||
|
365 | <td class="annotate"> | |||
|
366 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#16" | |||
|
367 | title="7c3facd7c58a: a">test@0</a> | |||
|
368 | </td> | |||
|
369 | <td class="source"><a href="#l16" id="l16"> 16</a> <span class="n">conn</span> <span class="o">=</span> <span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></td> | |||
|
370 | </tr> | |||
|
371 | <tr class="parity0"> | |||
|
372 | <td class="annotate"> | |||
|
373 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#17" | |||
|
374 | title="7c3facd7c58a: a">test@0</a> | |||
|
375 | </td> | |||
|
376 | <td class="source"><a href="#l17" id="l17"> 17</a> <span class="n">conn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">"GET"</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">2</span><span class="p">])</span></td> | |||
|
377 | </tr> | |||
|
378 | <tr class="parity1"> | |||
|
379 | <td class="annotate"> | |||
|
380 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#18" | |||
|
381 | title="7c3facd7c58a: a">test@0</a> | |||
|
382 | </td> | |||
|
383 | <td class="source"><a href="#l18" id="l18"> 18</a> <span class="n">response</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span></td> | |||
|
384 | </tr> | |||
|
385 | <tr class="parity0"> | |||
|
386 | <td class="annotate"> | |||
|
387 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#19" | |||
|
388 | title="7c3facd7c58a: a">test@0</a> | |||
|
389 | </td> | |||
|
390 | <td class="source"><a href="#l19" id="l19"> 19</a> <span class="kn">print</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">reason</span></td> | |||
|
391 | </tr> | |||
|
392 | <tr class="parity1"> | |||
|
393 | <td class="annotate"> | |||
|
394 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#20" | |||
|
395 | title="7c3facd7c58a: a">test@0</a> | |||
|
396 | </td> | |||
|
397 | <td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></td> | |||
|
398 | </tr> | |||
|
399 | <tr class="parity0"> | |||
|
400 | <td class="annotate"> | |||
|
401 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#21" | |||
|
402 | title="7c3facd7c58a: a">test@0</a> | |||
|
403 | </td> | |||
|
404 | <td class="source"><a href="#l21" id="l21"> 21</a> <span class="kn">if</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span></td> | |||
|
405 | </tr> | |||
|
406 | <tr class="parity1"> | |||
|
407 | <td class="annotate"> | |||
|
408 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#22" | |||
|
409 | title="7c3facd7c58a: a">test@0</a> | |||
|
410 | </td> | |||
|
411 | <td class="source"><a href="#l22" id="l22"> 22</a> <span class="kn">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">))</span></td> | |||
|
412 | </tr> | |||
|
413 | <tr class="parity0"> | |||
|
414 | <td class="annotate"> | |||
|
415 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#23" | |||
|
416 | title="7c3facd7c58a: a">test@0</a> | |||
|
417 | </td> | |||
|
418 | <td class="source"><a href="#l23" id="l23"> 23</a> <span class="kn">print</span></td> | |||
|
419 | </tr> | |||
|
420 | <tr class="parity1"> | |||
|
421 | <td class="annotate"> | |||
|
422 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#24" | |||
|
423 | title="7c3facd7c58a: a">test@0</a> | |||
|
424 | </td> | |||
|
425 | <td class="source"><a href="#l24" id="l24"> 24</a> <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">()</span></td> | |||
|
426 | </tr> | |||
|
427 | <tr class="parity0"> | |||
|
428 | <td class="annotate"> | |||
|
429 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#25" | |||
|
430 | title="7c3facd7c58a: a">test@0</a> | |||
|
431 | </td> | |||
|
432 | <td class="source"><a href="#l25" id="l25"> 25</a> <span class="n">data</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">'\d+ years'</span><span class="p">,</span> <span class="s">'many years'</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span></td> | |||
|
433 | </tr> | |||
|
434 | <tr class="parity1"> | |||
|
435 | <td class="annotate"> | |||
|
436 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#26" | |||
|
437 | title="7c3facd7c58a: a">test@0</a> | |||
|
438 | </td> | |||
|
439 | <td class="source"><a href="#l26" id="l26"> 26</a> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></td> | |||
|
440 | </tr> | |||
|
441 | <tr class="parity0"> | |||
|
442 | <td class="annotate"> | |||
|
443 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#27" | |||
|
444 | title="7c3facd7c58a: a">test@0</a> | |||
|
445 | </td> | |||
|
446 | <td class="source"><a href="#l27" id="l27"> 27</a> </td> | |||
|
447 | </tr> | |||
|
448 | <tr class="parity1"> | |||
|
449 | <td class="annotate"> | |||
|
450 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#28" | |||
|
451 | title="7c3facd7c58a: a">test@0</a> | |||
|
452 | </td> | |||
|
453 | <td class="source"><a href="#l28" id="l28"> 28</a> <span class="kn">if</span> <span class="mf">200</span> <span class="o"><=</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o"><=</span> <span class="mf">299</span><span class="p">:</span></td> | |||
|
454 | </tr> | |||
|
455 | <tr class="parity0"> | |||
|
456 | <td class="annotate"> | |||
|
457 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#29" | |||
|
458 | title="7c3facd7c58a: a">test@0</a> | |||
|
459 | </td> | |||
|
460 | <td class="source"><a href="#l29" id="l29"> 29</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">0</span><span class="p">)</span></td> | |||
|
461 | </tr> | |||
|
462 | <tr class="parity1"> | |||
|
463 | <td class="annotate"> | |||
|
464 | <a href="/annotate/7c3facd7c58a/get-with-headers.py#30" | |||
|
465 | title="7c3facd7c58a: a">test@0</a> | |||
|
466 | </td> | |||
|
467 | <td class="source"><a href="#l30" id="l30"> 30</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></td> | |||
|
468 | </tr> | |||
259 | </table> |
|
469 | </table> | |
260 | </div> |
|
470 | </div> | |
261 | </div> |
|
471 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now