comparison mercurial/hgweb/server.py @ 5835:bd34f0ac3cb0

adding "prefix" option to "hg serve" (command line and [web] section) allows "hg serve" to serve from a different path than '/' (server root)
author Michele Cella <michele.cella@gmail.com>
date Wed, 09 Jan 2008 11:15:00 +0100
parents 1b365c5723bc
children f25070ecf334
comparison
equal deleted inserted replaced
5834:5e7a8ea375a6 5835:bd34f0ac3cb0
74 74
75 def do_GET(self): 75 def do_GET(self):
76 self.do_POST() 76 self.do_POST()
77 77
78 def do_hgweb(self): 78 def do_hgweb(self):
79 path_info, query = _splitURI(self.path) 79 path, query = _splitURI(self.path)
80 80
81 env = {} 81 env = {}
82 env['GATEWAY_INTERFACE'] = 'CGI/1.1' 82 env['GATEWAY_INTERFACE'] = 'CGI/1.1'
83 env['REQUEST_METHOD'] = self.command 83 env['REQUEST_METHOD'] = self.command
84 env['SERVER_NAME'] = self.server.server_name 84 env['SERVER_NAME'] = self.server.server_name
85 env['SERVER_PORT'] = str(self.server.server_port) 85 env['SERVER_PORT'] = str(self.server.server_port)
86 env['REQUEST_URI'] = self.path 86 env['REQUEST_URI'] = self.path
87 env['SCRIPT_NAME'] = '' 87 env['SCRIPT_NAME'] = self.server.prefix
88 env['PATH_INFO'] = path_info 88 env['PATH_INFO'] = path[len(self.server.prefix):]
89 env['REMOTE_HOST'] = self.client_address[0] 89 env['REMOTE_HOST'] = self.client_address[0]
90 env['REMOTE_ADDR'] = self.client_address[0] 90 env['REMOTE_ADDR'] = self.client_address[0]
91 if query: 91 if query:
92 env['QUERY_STRING'] = query 92 env['QUERY_STRING'] = query
93 93
204 myui = ui 204 myui = ui
205 else: 205 else:
206 myui = repo.ui 206 myui = repo.ui
207 address = myui.config("web", "address", "") 207 address = myui.config("web", "address", "")
208 port = int(myui.config("web", "port", 8000)) 208 port = int(myui.config("web", "port", 8000))
209 prefix = myui.config("web", "prefix", "").rstrip("/")
209 use_ipv6 = myui.configbool("web", "ipv6") 210 use_ipv6 = myui.configbool("web", "ipv6")
210 webdir_conf = myui.config("web", "webdir_conf") 211 webdir_conf = myui.config("web", "webdir_conf")
211 ssl_cert = myui.config("web", "certificate") 212 ssl_cert = myui.config("web", "certificate")
212 accesslog = openlog(myui.config("web", "accesslog", "-"), sys.stdout) 213 accesslog = openlog(myui.config("web", "accesslog", "-"), sys.stdout)
213 errorlog = openlog(myui.config("web", "errorlog", "-"), sys.stderr) 214 errorlog = openlog(myui.config("web", "errorlog", "-"), sys.stderr)
252 addr = address 253 addr = address
253 if addr in ('', '::'): 254 if addr in ('', '::'):
254 addr = socket.gethostname() 255 addr = socket.gethostname()
255 256
256 self.addr, self.port = addr, port 257 self.addr, self.port = addr, port
258 self.prefix = prefix
257 259
258 if ssl_cert: 260 if ssl_cert:
259 try: 261 try:
260 from OpenSSL import SSL 262 from OpenSSL import SSL
261 ctx = SSL.Context(SSL.SSLv23_METHOD) 263 ctx = SSL.Context(SSL.SSLv23_METHOD)