35 |
35 |
|
36 |
36 |
class HttpClientRequest(object):
|
37 |
37 |
def __init__(self, host, port, method, path, headers=None, post_data=None,
|
38 |
|
read_timeout=None, curl_config_fn=None):
|
|
38 |
read_timeout=None, curl_config_fn=None, nicename=None):
|
39 |
39 |
"""Describes an HTTP request.
|
40 |
40 |
|
41 |
41 |
@type host: string
|
... | ... | |
57 |
57 |
@param curl_config_fn: Function to configure cURL object before request
|
58 |
58 |
(Note: if the function configures the connection in
|
59 |
59 |
a way where it wouldn't be efficient to reuse them,
|
60 |
|
a "identity" property should be defined, see
|
|
60 |
an "identity" property should be defined, see
|
61 |
61 |
L{HttpClientRequest.identity})
|
|
62 |
@type nicename: string
|
|
63 |
@param nicename: Name, presentable to a user, to describe this request (no
|
|
64 |
whitespace)
|
62 |
65 |
|
63 |
66 |
"""
|
64 |
67 |
assert path.startswith("/"), "Path must start with slash (/)"
|
... | ... | |
71 |
74 |
self.path = path
|
72 |
75 |
self.read_timeout = read_timeout
|
73 |
76 |
self.curl_config_fn = curl_config_fn
|
|
77 |
self.nicename = nicename
|
74 |
78 |
|
75 |
79 |
if post_data is None:
|
76 |
80 |
self.post_data = ""
|
... | ... | |
500 |
504 |
for pclient in self._pending_fn():
|
501 |
505 |
req = pclient.client.GetCurrentRequest()
|
502 |
506 |
if req:
|
503 |
|
result.append(("rpc/%s%s" % (req.host, req.path), None, None,
|
|
507 |
if req.nicename is None:
|
|
508 |
name = "%s%s" % (req.host, req.path)
|
|
509 |
else:
|
|
510 |
name = req.nicename
|
|
511 |
result.append(("rpc/%s" % name, None, None,
|
504 |
512 |
[("thread", [owner_name])]))
|
505 |
513 |
|
506 |
514 |
return result
|