Here are the examples of the python api twisted.web.server.version taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Example 1
Project: shiji Source File: test_init.py
def test_change_ident(self):
new_name = "Bongo"
new_version = "1.91"
shiji.change_server_ident(new_name, new_version)
self.assertEqual(shiji.server_ident["server_name"], new_name)
self.assertEqual(shiji.server_ident["server_version"], new_version)
self.assertEqual(server.version, "Bongo/1.91")
3
Example 2
Project: shiji Source File: __init__.py
def change_server_ident(name, version=None):
"""
Changes the 'Server' HTTP header globally.
Arguments:
name (string) - Name of the server app.
version (string) (optional) - Version of the server app.
"""
global server_ident
server_ident["server_name"] = name
if version != None and len(version) > 0:
server_ident["server_version"] = str(version)
version_text = "/%s" % server_ident["server_version"]
else:
version_text = ""
server.version = server_ident["server_name"] + version_text
0
Example 3
Project: SubliminalCollaborator Source File: twcgi.py
def render(self, request):
"""
Do various things to conform to the CGI specification.
I will set up the usual slew of environment variables, then spin off a
process.
@type request: L{twisted.web.http.Request}
@param request: An HTTP request.
"""
script_name = "/"+string.join(request.prepath, '/')
serverName = string.split(request.getRequestHostname(), ':')[0]
env = {"SERVER_SOFTWARE": server.version,
"SERVER_NAME": serverName,
"GATEWAY_INTERFACE": "CGI/1.1",
"SERVER_PROTOCOL": request.clientproto,
"SERVER_PORT": str(request.getHost().port),
"REQUEST_METHOD": request.method,
"SCRIPT_NAME": script_name, # XXX
"SCRIPT_FILENAME": self.filename,
"REQUEST_URI": request.uri,
}
client = request.getClient()
if client is not None:
env['REMOTE_HOST'] = client
ip = request.getClientIP()
if ip is not None:
env['REMOTE_ADDR'] = ip
pp = request.postpath
if pp:
env["PATH_INFO"] = "/"+string.join(pp, '/')
if hasattr(request, "content"):
# request.content is either a StringIO or a TemporaryFile, and
# the file pointer is sitting at the beginning (seek(0,0))
request.content.seek(0,2)
length = request.content.tell()
request.content.seek(0,0)
env['CONTENT_LENGTH'] = str(length)
qindex = string.find(request.uri, '?')
if qindex != -1:
qs = env['QUERY_STRING'] = request.uri[qindex+1:]
if '=' in qs:
qargs = []
else:
qargs = [urllib.unquote(x) for x in qs.split('+')]
else:
env['QUERY_STRING'] = ''
qargs = []
# Propogate HTTP headers
for title, header in request.getAllHeaders().items():
envname = string.upper(string.replace(title, '-', '_'))
if title not in ('content-type', 'content-length'):
envname = "HTTP_" + envname
env[envname] = header
# Propogate our environment
for key, value in os.environ.items():
if key not in env:
env[key] = value
# And they're off!
self.runProcess(env, request, qargs)
return server.NOT_DONE_YET