Show More
@@ -321,8 +321,11 b' class hgweb(object):' | |||||
321 | res.headers['Content-Security-Policy'] = rctx.csp |
|
321 | res.headers['Content-Security-Policy'] = rctx.csp | |
322 |
|
322 | |||
323 | # /api/* is reserved for various API implementations. Dispatch |
|
323 | # /api/* is reserved for various API implementations. Dispatch | |
324 | # accordingly. |
|
324 | # accordingly. But URL paths can conflict with subrepos and virtual | |
325 | if req.dispatchparts and req.dispatchparts[0] == b'api': |
|
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 | wireprotoserver.handlewsgiapirequest(rctx, req, res, |
|
329 | wireprotoserver.handlewsgiapirequest(rctx, req, res, | |
327 | self.check_perm) |
|
330 | self.check_perm) | |
328 | return res.sendresponse() |
|
331 | return res.sendresponse() |
@@ -8,43 +8,133 b'' | |||||
8 |
|
8 | |||
9 | Request to /api fails unless web.apiserver is enabled |
|
9 | Request to /api fails unless web.apiserver is enabled | |
10 |
|
10 | |||
11 | $ send << EOF |
|
11 | $ get-with-headers.py $LOCALIP:$HGPORT api | |
12 | > httprequest GET api |
|
12 | 400 no such method: api | |
13 | > user-agent: test |
|
13 | ||
14 | > EOF |
|
14 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
15 | using raw connection to peer |
|
15 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> | |
16 | s> GET /api HTTP/1.1\r\n |
|
16 | <head> | |
17 | s> Accept-Encoding: identity\r\n |
|
17 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> | |
18 | s> user-agent: test\r\n |
|
18 | <meta name="robots" content="index, nofollow" /> | |
19 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
19 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> | |
20 | s> \r\n |
|
20 | <script type="text/javascript" src="/static/mercurial.js"></script> | |
21 | s> makefile('rb', None) |
|
21 | ||
22 | s> HTTP/1.1 404 Not Found\r\n |
|
22 | <title>$TESTTMP/server: error</title> | |
23 | s> Server: testing stub value\r\n |
|
23 | </head> | |
24 | s> Date: $HTTP_DATE$\r\n |
|
24 | <body> | |
25 | s> Content-Type: text/plain\r\n |
|
25 | ||
26 | s> Content-Length: 44\r\n |
|
26 | <div class="container"> | |
27 | s> \r\n |
|
27 | <div class="menu"> | |
28 | s> Experimental API server endpoint not enabled |
|
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 |
|
75 | $ get-with-headers.py $LOCALIP:$HGPORT api/ | |
31 | > httprequest GET api/ |
|
76 | 400 no such method: api | |
32 | > user-agent: test |
|
77 | ||
33 | > EOF |
|
78 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
34 | using raw connection to peer |
|
79 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> | |
35 | s> GET /api/ HTTP/1.1\r\n |
|
80 | <head> | |
36 | s> Accept-Encoding: identity\r\n |
|
81 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> | |
37 | s> user-agent: test\r\n |
|
82 | <meta name="robots" content="index, nofollow" /> | |
38 | s> host: $LOCALIP:$HGPORT\r\n (glob) |
|
83 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> | |
39 | s> \r\n |
|
84 | <script type="text/javascript" src="/static/mercurial.js"></script> | |
40 | s> makefile('rb', None) |
|
85 | ||
41 | s> HTTP/1.1 404 Not Found\r\n |
|
86 | <title>$TESTTMP/server: error</title> | |
42 | s> Server: testing stub value\r\n |
|
87 | </head> | |
43 | s> Date: $HTTP_DATE$\r\n |
|
88 | <body> | |
44 | s> Content-Type: text/plain\r\n |
|
89 | ||
45 | s> Content-Length: 44\r\n |
|
90 | <div class="container"> | |
46 | s> \r\n |
|
91 | <div class="menu"> | |
47 | s> Experimental API server endpoint not enabled |
|
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 | Restart server with support for API server |
|
139 | Restart server with support for API server | |
50 |
|
140 |
General Comments 0
You need to be logged in to leave comments.
Login now