comparison mercurial/hgweb/hgweb_mod.py @ 35856:ef3a24a023ec

wireprotoserver: rename hgweb.protocol to wireprotoserver (API) The HTTP wire protocol server / response handler is currently defined in the hgweb sub-package. That only kind of makes sense. hgweb does contain most of the HTTP server code. However, hgweb is more tailored for providing HTTP server and WSGI scaffolding and serving hgweb requests. The wire protocol is kind of its own beast. In addition, the code for HTTP and SSH wire protocol handling is actually pretty small and it needs to stay in sync to ensure parity between the transport implementations. We rename mercurial/hgweb/protocol.py to mercurial/wireprotoserver.py. The new module will eventually become the home of the SSH handler as well. .. api:: Content from mercurial.hgweb.protocol has been moved to mercurial.wireprotoserver. Differential Revision: https://phab.mercurial-scm.org/D1965
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 31 Jan 2018 11:09:07 -0800
parents da5d5ea7d696
children a42455b3dbf8
comparison
equal deleted inserted replaced
35855:69d7fcd91696 35856:ef3a24a023ec
34 repoview, 34 repoview,
35 templatefilters, 35 templatefilters,
36 templater, 36 templater,
37 ui as uimod, 37 ui as uimod,
38 util, 38 util,
39 wireprotoserver,
39 ) 40 )
40 41
41 from . import ( 42 from . import (
42 protocol,
43 webcommands, 43 webcommands,
44 webutil, 44 webutil,
45 wsgicgi, 45 wsgicgi,
46 ) 46 )
47 47
360 # process this if it's a protocol request 360 # process this if it's a protocol request
361 # protocol bits don't need to create any URLs 361 # protocol bits don't need to create any URLs
362 # and the clients always use the old URL structure 362 # and the clients always use the old URL structure
363 363
364 cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0]) 364 cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0])
365 if protocol.iscmd(cmd): 365 if wireprotoserver.iscmd(cmd):
366 try: 366 try:
367 if query: 367 if query:
368 raise ErrorResponse(HTTP_NOT_FOUND) 368 raise ErrorResponse(HTTP_NOT_FOUND)
369 if cmd in perms: 369 if cmd in perms:
370 self.check_perm(rctx, req, perms[cmd]) 370 self.check_perm(rctx, req, perms[cmd])
371 return protocol.call(rctx.repo, req, cmd) 371 return wireprotoserver.call(rctx.repo, req, cmd)
372 except ErrorResponse as inst: 372 except ErrorResponse as inst:
373 # A client that sends unbundle without 100-continue will 373 # A client that sends unbundle without 100-continue will
374 # break if we respond early. 374 # break if we respond early.
375 if (cmd == 'unbundle' and 375 if (cmd == 'unbundle' and
376 (req.env.get('HTTP_EXPECT', 376 (req.env.get('HTTP_EXPECT',
377 '').lower() != '100-continue') or 377 '').lower() != '100-continue') or
378 req.env.get('X-HgHttp2', '')): 378 req.env.get('X-HgHttp2', '')):
379 req.drain() 379 req.drain()
380 else: 380 else:
381 req.headers.append((r'Connection', r'Close')) 381 req.headers.append((r'Connection', r'Close'))
382 req.respond(inst, protocol.HGTYPE, 382 req.respond(inst, wireprotoserver.HGTYPE,
383 body='0\n%s\n' % inst) 383 body='0\n%s\n' % inst)
384 return '' 384 return ''
385 385
386 # translate user-visible url structure to internal structure 386 # translate user-visible url structure to internal structure
387 387