Show More
@@ -14,7 +14,7 b' cd test' | |||
|
14 | 14 | cp $TESTDIR/get-with-headers.py ./ |
|
15 | 15 | |
|
16 | 16 | # check for UnicodeDecodeError with iso-8859-1 file contents |
|
17 | python -c 'fp = open("isolatin", "w"); fp.write("h\xFCbsch\n"); fp.close();' | |
|
17 | python -c 'fp = open("isolatin.txt", "w"); fp.write("h\xFCbsch\n"); fp.close();' | |
|
18 | 18 | |
|
19 | 19 | hg ci -Ama |
|
20 | 20 | |
@@ -27,7 +27,7 b' echo % hgweb filerevision, html' | |||
|
27 | 27 | | sed "s/class=\"k\"/class=\"kn\"/g" |
|
28 | 28 | |
|
29 | 29 | echo % hgweb filerevision, html |
|
30 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/isolatin') \ | |
|
30 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/isolatin.txt') \ | |
|
31 | 31 | | sed "s/class=\"k\"/class=\"kn\"/g" |
|
32 | 32 | |
|
33 | 33 | echo % hgweb fileannotate, html |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | adding get-with-headers.py |
|
2 | adding isolatin | |
|
2 | adding isolatin.txt | |
|
3 | 3 | % hg serve |
|
4 | 4 | % hgweb filerevision, html |
|
5 | 5 | 200 Script output follows |
@@ -12,7 +12,7 b' 200 Script output follows' | |||
|
12 | 12 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
13 | 13 | |
|
14 | 14 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
15 |
<title>test: |
|
|
15 | <title>test: 7c3facd7c58a get-with-headers.py</title> | |
|
16 | 16 | </head> |
|
17 | 17 | <body> |
|
18 | 18 | |
@@ -23,26 +23,26 b' 200 Script output follows' | |||
|
23 | 23 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
24 | 24 | </div> |
|
25 | 25 | <ul> |
|
26 |
<li><a href="/shortlog/ |
|
|
27 |
<li><a href="/graph/ |
|
|
26 | <li><a href="/shortlog/7c3facd7c58a">log</a></li> | |
|
27 | <li><a href="/graph/7c3facd7c58a">graph</a></li> | |
|
28 | 28 | <li><a href="/tags">tags</a></li> |
|
29 | 29 | </ul> |
|
30 | 30 | <ul> |
|
31 |
<li><a href="/rev/ |
|
|
32 |
<li><a href="/file/ |
|
|
31 | <li><a href="/rev/7c3facd7c58a">changeset</a></li> | |
|
32 | <li><a href="/file/7c3facd7c58a/">browse</a></li> | |
|
33 | 33 | </ul> |
|
34 | 34 | <ul> |
|
35 | 35 | <li class="active">file</li> |
|
36 |
<li><a href="/diff/ |
|
|
37 |
<li><a href="/annotate/ |
|
|
38 |
<li><a href="/log/ |
|
|
39 |
<li><a href="/raw-file/ |
|
|
36 | <li><a href="/diff/7c3facd7c58a/get-with-headers.py">diff</a></li> | |
|
37 | <li><a href="/annotate/7c3facd7c58a/get-with-headers.py">annotate</a></li> | |
|
38 | <li><a href="/log/7c3facd7c58a/get-with-headers.py">file log</a></li> | |
|
39 | <li><a href="/raw-file/7c3facd7c58a/get-with-headers.py">raw</a></li> | |
|
40 | 40 | </ul> |
|
41 | 41 | </div> |
|
42 | 42 | |
|
43 | 43 | <div class="main"> |
|
44 | 44 | <h2><a href="/">test</a></h2> |
|
45 |
<h3>view get-with-headers.py @ 0: |
|
|
45 | <h3>view get-with-headers.py @ 0:7c3facd7c58a</h3> | |
|
46 | 46 | |
|
47 | 47 | <form class="search" action="/log"> |
|
48 | 48 | |
@@ -97,7 +97,7 b' 200 Script output follows' | |||
|
97 | 97 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
98 | 98 | |
|
99 | 99 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
100 |
<title>test: |
|
|
100 | <title>test: 7c3facd7c58a isolatin.txt</title> | |
|
101 | 101 | </head> |
|
102 | 102 | <body> |
|
103 | 103 | |
@@ -108,26 +108,26 b' 200 Script output follows' | |||
|
108 | 108 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
109 | 109 | </div> |
|
110 | 110 | <ul> |
|
111 |
<li><a href="/shortlog/ |
|
|
112 |
<li><a href="/graph/ |
|
|
111 | <li><a href="/shortlog/7c3facd7c58a">log</a></li> | |
|
112 | <li><a href="/graph/7c3facd7c58a">graph</a></li> | |
|
113 | 113 | <li><a href="/tags">tags</a></li> |
|
114 | 114 | </ul> |
|
115 | 115 | <ul> |
|
116 |
<li><a href="/rev/ |
|
|
117 |
<li><a href="/file/ |
|
|
116 | <li><a href="/rev/7c3facd7c58a">changeset</a></li> | |
|
117 | <li><a href="/file/7c3facd7c58a/">browse</a></li> | |
|
118 | 118 | </ul> |
|
119 | 119 | <ul> |
|
120 | 120 | <li class="active">file</li> |
|
121 |
<li><a href="/diff/ |
|
|
122 |
<li><a href="/annotate/ |
|
|
123 |
<li><a href="/log/ |
|
|
124 |
<li><a href="/raw-file/ |
|
|
121 | <li><a href="/diff/7c3facd7c58a/isolatin.txt">diff</a></li> | |
|
122 | <li><a href="/annotate/7c3facd7c58a/isolatin.txt">annotate</a></li> | |
|
123 | <li><a href="/log/7c3facd7c58a/isolatin.txt">file log</a></li> | |
|
124 | <li><a href="/raw-file/7c3facd7c58a/isolatin.txt">raw</a></li> | |
|
125 | 125 | </ul> |
|
126 | 126 | </div> |
|
127 | 127 | |
|
128 | 128 | <div class="main"> |
|
129 | 129 | <h2><a href="/">test</a></h2> |
|
130 |
<h3>view isolatin |
|
|
130 | <h3>view isolatin.txt @ 0:7c3facd7c58a</h3> | |
|
131 | 131 | |
|
132 | 132 | <form class="search" action="/log"> |
|
133 | 133 | |
@@ -193,27 +193,27 b' 200 Script output follows' | |||
|
193 | 193 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
194 | 194 | </div> |
|
195 | 195 | <ul> |
|
196 |
<li><a href="/shortlog/ |
|
|
197 |
<li><a href="/graph/ |
|
|
196 | <li><a href="/shortlog/7c3facd7c58a">log</a></li> | |
|
197 | <li><a href="/graph/7c3facd7c58a">graph</a></li> | |
|
198 | 198 | <li><a href="/tags">tags</a></li> |
|
199 | 199 | </ul> |
|
200 | 200 | |
|
201 | 201 | <ul> |
|
202 |
<li><a href="/rev/ |
|
|
203 |
<li><a href="/file/ |
|
|
202 | <li><a href="/rev/7c3facd7c58a">changeset</a></li> | |
|
203 | <li><a href="/file/7c3facd7c58a/">browse</a></li> | |
|
204 | 204 | </ul> |
|
205 | 205 | <ul> |
|
206 |
<li><a href="/file/ |
|
|
207 |
<li><a href="/diff/ |
|
|
206 | <li><a href="/file/7c3facd7c58a/get-with-headers.py">file</a></li> | |
|
207 | <li><a href="/diff/7c3facd7c58a/get-with-headers.py">diff</a></li> | |
|
208 | 208 | <li class="active">annotate</li> |
|
209 |
<li><a href="/log/ |
|
|
210 |
<li><a href="/raw-annotate/ |
|
|
209 | <li><a href="/log/7c3facd7c58a/get-with-headers.py">file log</a></li> | |
|
210 | <li><a href="/raw-annotate/7c3facd7c58a/get-with-headers.py">raw</a></li> | |
|
211 | 211 | </ul> |
|
212 | 212 | </div> |
|
213 | 213 | |
|
214 | 214 | <div class="main"> |
|
215 | 215 | <h2><a href="/">test</a></h2> |
|
216 |
<h3>annotate get-with-headers.py @ 0: |
|
|
216 | <h3>annotate get-with-headers.py @ 0:7c3facd7c58a</h3> | |
|
217 | 217 | |
|
218 | 218 | <form class="search" action="/log"> |
|
219 | 219 | |
@@ -252,7 +252,7 b' files, or words in the commit message</d' | |||
|
252 | 252 | <th class="annotate">rev</th> |
|
253 | 253 | <th class="line"> line source</th> |
|
254 | 254 | </tr> |
|
255 |
<tr class="parity0"><td class="annotate"><a href="/annotate/ |
|
|
255 | <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> | |
|
256 | 256 | </table> |
|
257 | 257 | </div> |
|
258 | 258 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now