##// END OF EJS Templates
hgweb: reuse body file object when hgwebdir calls hgweb (issue5851)...
Gregory Szorc -
r37836:877185de stable
parent child Browse files
Show More
@@ -428,7 +428,10 b' class hgwebdir(object):'
428 428 uenv.iteritems()}
429 429 req = requestmod.parserequestfromenv(
430 430 uenv, reponame=virtualrepo,
431 altbaseurl=self.ui.config('web', 'baseurl'))
431 altbaseurl=self.ui.config('web', 'baseurl'),
432 # Reuse wrapped body file object otherwise state
433 # tracking can get confused.
434 bodyfh=req.bodyfh)
432 435 try:
433 436 # ensure caller gets private copy of ui
434 437 repo = hg.repository(self.ui.copy(), real)
@@ -124,7 +124,7 b' class parsedrequest(object):'
124 124 # WSGI environment dict, unmodified.
125 125 rawenv = attr.ib()
126 126
127 def parserequestfromenv(env, reponame=None, altbaseurl=None):
127 def parserequestfromenv(env, reponame=None, altbaseurl=None, bodyfh=None):
128 128 """Parse URL components from environment variables.
129 129
130 130 WSGI defines request attributes via environment variables. This function
@@ -144,6 +144,9 b' def parserequestfromenv(env, reponame=No'
144 144 if the request were to ``http://myserver:9000/prefix/rev/@``. In other
145 145 words, ``wsgi.url_scheme``, ``SERVER_NAME``, ``SERVER_PORT``, and
146 146 ``SCRIPT_NAME`` are all effectively replaced by components from this URL.
147
148 ``bodyfh`` can be used to specify a file object to read the request body
149 from. If not defined, ``wsgi.input`` from the environment dict is used.
147 150 """
148 151 # PEP 3333 defines the WSGI spec and is a useful reference for this code.
149 152
@@ -307,9 +310,10 b' def parserequestfromenv(env, reponame=No'
307 310 if 'CONTENT_TYPE' in env and 'HTTP_CONTENT_TYPE' not in env:
308 311 headers['Content-Type'] = env['CONTENT_TYPE']
309 312
310 bodyfh = env['wsgi.input']
311 if 'Content-Length' in headers:
312 bodyfh = util.cappedreader(bodyfh, int(headers['Content-Length']))
313 if bodyfh is None:
314 bodyfh = env['wsgi.input']
315 if 'Content-Length' in headers:
316 bodyfh = util.cappedreader(bodyfh, int(headers['Content-Length']))
313 317
314 318 return parsedrequest(method=env['REQUEST_METHOD'],
315 319 url=fullurl, baseurl=baseurl,
@@ -380,3 +380,47 b' Make phases updates work'
380 380 #endif
381 381
382 382 $ cd ..
383
384 Pushing via hgwebdir works
385
386 $ hg init hgwebdir
387 $ cd hgwebdir
388 $ echo 0 > a
389 $ hg -q commit -A -m initial
390 $ cd ..
391
392 $ cat > web.conf << EOF
393 > [paths]
394 > / = *
395 > [web]
396 > push_ssl = false
397 > allow_push = *
398 > EOF
399
400 $ hg serve --web-conf web.conf -p $HGPORT -d --pid-file hg.pid
401 $ cat hg.pid > $DAEMON_PIDS
402
403 $ hg clone http://localhost:$HGPORT/hgwebdir hgwebdir-local
404 requesting all changes
405 adding changesets
406 adding manifests
407 adding file changes
408 added 1 changesets with 1 changes to 1 files
409 new changesets 98a3f8f02ba7
410 updating to branch default
411 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
412 $ cd hgwebdir-local
413 $ echo commit > a
414 $ hg commit -m 'local commit'
415
416 $ hg push
417 pushing to http://localhost:$HGPORT/hgwebdir
418 searching for changes
419 remote: adding changesets
420 remote: adding manifests
421 remote: adding file changes
422 remote: added 1 changesets with 1 changes to 1 files
423
424 $ killdaemons.py
425
426 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now