Show More
@@ -321,8 +321,11 b' class hgweb(object):' | |||
|
321 | 321 | res.headers['Content-Security-Policy'] = rctx.csp |
|
322 | 322 | |
|
323 | 323 | # /api/* is reserved for various API implementations. Dispatch |
|
324 | # accordingly. | |
|
325 | if req.dispatchparts and req.dispatchparts[0] == b'api': | |
|
324 | # accordingly. But URL paths can conflict with subrepos and virtual | |
|
325 | # repos in hgwebdir. So until we have a workaround for this, only | |
|
326 | # expose the URLs if the feature is enabled. | |
|
327 | apienabled = rctx.repo.ui.configbool('experimental', 'web.apiserver') | |
|
328 | if apienabled and req.dispatchparts and req.dispatchparts[0] == b'api': | |
|
326 | 329 | wireprotoserver.handlewsgiapirequest(rctx, req, res, |
|
327 | 330 | self.check_perm) |
|
328 | 331 | return res.sendresponse() |
@@ -8,43 +8,133 b'' | |||
|
8 | 8 | |
|
9 | 9 | Request to /api fails unless web.apiserver is enabled |
|
10 | 10 | |
|
11 | $ send << EOF | |
|
12 | > httprequest GET api | |
|
13 | > user-agent: test | |
|
14 | > EOF | |
|
15 | using raw connection to peer | |
|
16 | s> GET /api HTTP/1.1\r\n | |
|
17 | s> Accept-Encoding: identity\r\n | |
|
18 | s> user-agent: test\r\n | |
|
19 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |
|
20 | s> \r\n | |
|
21 | s> makefile('rb', None) | |
|
22 | s> HTTP/1.1 404 Not Found\r\n | |
|
23 | s> Server: testing stub value\r\n | |
|
24 | s> Date: $HTTP_DATE$\r\n | |
|
25 | s> Content-Type: text/plain\r\n | |
|
26 | s> Content-Length: 44\r\n | |
|
27 | s> \r\n | |
|
28 | s> Experimental API server endpoint not enabled | |
|
11 | $ get-with-headers.py $LOCALIP:$HGPORT api | |
|
12 | 400 no such method: api | |
|
13 | ||
|
14 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
|
15 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> | |
|
16 | <head> | |
|
17 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> | |
|
18 | <meta name="robots" content="index, nofollow" /> | |
|
19 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> | |
|
20 | <script type="text/javascript" src="/static/mercurial.js"></script> | |
|
21 | ||
|
22 | <title>$TESTTMP/server: error</title> | |
|
23 | </head> | |
|
24 | <body> | |
|
25 | ||
|
26 | <div class="container"> | |
|
27 | <div class="menu"> | |
|
28 | <div class="logo"> | |
|
29 | <a href="https://mercurial-scm.org/"> | |
|
30 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a> | |
|
31 | </div> | |
|
32 | <ul> | |
|
33 | <li><a href="/shortlog">log</a></li> | |
|
34 | <li><a href="/graph">graph</a></li> | |
|
35 | <li><a href="/tags">tags</a></li> | |
|
36 | <li><a href="/bookmarks">bookmarks</a></li> | |
|
37 | <li><a href="/branches">branches</a></li> | |
|
38 | </ul> | |
|
39 | <ul> | |
|
40 | <li><a href="/help">help</a></li> | |
|
41 | </ul> | |
|
42 | </div> | |
|
43 | ||
|
44 | <div class="main"> | |
|
45 | ||
|
46 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> | |
|
47 | <h3>error</h3> | |
|
48 | ||
|
49 | ||
|
50 | <form class="search" action="/log"> | |
|
51 | ||
|
52 | <p><input name="rev" id="search1" type="text" size="30" value="" /></p> | |
|
53 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision | |
|
54 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> | |
|
55 | </form> | |
|
56 | ||
|
57 | <div class="description"> | |
|
58 | <p> | |
|
59 | An error occurred while processing your request: | |
|
60 | </p> | |
|
61 | <p> | |
|
62 | no such method: api | |
|
63 | </p> | |
|
64 | </div> | |
|
65 | </div> | |
|
66 | </div> | |
|
67 | ||
|
68 | ||
|
69 | ||
|
70 | </body> | |
|
71 | </html> | |
|
72 | ||
|
73 | [1] | |
|
29 | 74 | |
|
30 | $ send << EOF | |
|
31 | > httprequest GET api/ | |
|
32 | > user-agent: test | |
|
33 | > EOF | |
|
34 | using raw connection to peer | |
|
35 | s> GET /api/ HTTP/1.1\r\n | |
|
36 | s> Accept-Encoding: identity\r\n | |
|
37 | s> user-agent: test\r\n | |
|
38 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |
|
39 | s> \r\n | |
|
40 | s> makefile('rb', None) | |
|
41 | s> HTTP/1.1 404 Not Found\r\n | |
|
42 | s> Server: testing stub value\r\n | |
|
43 | s> Date: $HTTP_DATE$\r\n | |
|
44 | s> Content-Type: text/plain\r\n | |
|
45 | s> Content-Length: 44\r\n | |
|
46 | s> \r\n | |
|
47 | s> Experimental API server endpoint not enabled | |
|
75 | $ get-with-headers.py $LOCALIP:$HGPORT api/ | |
|
76 | 400 no such method: api | |
|
77 | ||
|
78 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
|
79 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> | |
|
80 | <head> | |
|
81 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> | |
|
82 | <meta name="robots" content="index, nofollow" /> | |
|
83 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> | |
|
84 | <script type="text/javascript" src="/static/mercurial.js"></script> | |
|
85 | ||
|
86 | <title>$TESTTMP/server: error</title> | |
|
87 | </head> | |
|
88 | <body> | |
|
89 | ||
|
90 | <div class="container"> | |
|
91 | <div class="menu"> | |
|
92 | <div class="logo"> | |
|
93 | <a href="https://mercurial-scm.org/"> | |
|
94 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a> | |
|
95 | </div> | |
|
96 | <ul> | |
|
97 | <li><a href="/shortlog">log</a></li> | |
|
98 | <li><a href="/graph">graph</a></li> | |
|
99 | <li><a href="/tags">tags</a></li> | |
|
100 | <li><a href="/bookmarks">bookmarks</a></li> | |
|
101 | <li><a href="/branches">branches</a></li> | |
|
102 | </ul> | |
|
103 | <ul> | |
|
104 | <li><a href="/help">help</a></li> | |
|
105 | </ul> | |
|
106 | </div> | |
|
107 | ||
|
108 | <div class="main"> | |
|
109 | ||
|
110 | <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2> | |
|
111 | <h3>error</h3> | |
|
112 | ||
|
113 | ||
|
114 | <form class="search" action="/log"> | |
|
115 | ||
|
116 | <p><input name="rev" id="search1" type="text" size="30" value="" /></p> | |
|
117 | <div id="hint">Find changesets by keywords (author, files, the commit message), revision | |
|
118 | number or hash, or <a href="/help/revsets">revset expression</a>.</div> | |
|
119 | </form> | |
|
120 | ||
|
121 | <div class="description"> | |
|
122 | <p> | |
|
123 | An error occurred while processing your request: | |
|
124 | </p> | |
|
125 | <p> | |
|
126 | no such method: api | |
|
127 | </p> | |
|
128 | </div> | |
|
129 | </div> | |
|
130 | </div> | |
|
131 | ||
|
132 | ||
|
133 | ||
|
134 | </body> | |
|
135 | </html> | |
|
136 | ||
|
137 | [1] | |
|
48 | 138 | |
|
49 | 139 | Restart server with support for API server |
|
50 | 140 |
General Comments 0
You need to be logged in to leave comments.
Login now