Show More
@@ -28,6 +28,11 b' Config::' | |||||
28 | # callsign is "FOO". |
|
28 | # callsign is "FOO". | |
29 | callsign = FOO |
|
29 | callsign = FOO | |
30 |
|
30 | |||
|
31 | # curl command to use. If not set (default), use builtin HTTP library to | |||
|
32 | # communicate. If set, use the specified curl command. This could be useful | |||
|
33 | # if you need to specify advanced options that is not easily supported by | |||
|
34 | # the internal library. | |||
|
35 | curlcmd = curl --connect-timeout 2 --retry 3 --silent | |||
31 | """ |
|
36 | """ | |
32 |
|
37 | |||
33 | from __future__ import absolute_import |
|
38 | from __future__ import absolute_import | |
@@ -108,12 +113,20 b' def callconduit(repo, name, params):' | |||||
108 | """call Conduit API, params is a dict. return json.loads result, or None""" |
|
113 | """call Conduit API, params is a dict. return json.loads result, or None""" | |
109 | host, token = readurltoken(repo) |
|
114 | host, token = readurltoken(repo) | |
110 | url, authinfo = util.url('/'.join([host, 'api', name])).authinfo() |
|
115 | url, authinfo = util.url('/'.join([host, 'api', name])).authinfo() | |
111 | urlopener = urlmod.opener(repo.ui, authinfo) |
|
|||
112 | repo.ui.debug('Conduit Call: %s %s\n' % (url, params)) |
|
116 | repo.ui.debug('Conduit Call: %s %s\n' % (url, params)) | |
113 | params = params.copy() |
|
117 | params = params.copy() | |
114 | params['api.token'] = token |
|
118 | params['api.token'] = token | |
115 |
|
|
119 | data = urlencodenested(params) | |
116 | body = urlopener.open(request).read() |
|
120 | curlcmd = repo.ui.config('phabricator', 'curlcmd') | |
|
121 | if curlcmd: | |||
|
122 | sin, sout = util.popen2('%s -d @- %s' % (curlcmd, util.shellquote(url))) | |||
|
123 | sin.write(data) | |||
|
124 | sin.close() | |||
|
125 | body = sout.read() | |||
|
126 | else: | |||
|
127 | urlopener = urlmod.opener(repo.ui, authinfo) | |||
|
128 | request = util.urlreq.request(url, data=data) | |||
|
129 | body = urlopener.open(request).read() | |||
117 | repo.ui.debug('Conduit Response: %s\n' % body) |
|
130 | repo.ui.debug('Conduit Response: %s\n' % body) | |
118 | parsed = json.loads(body) |
|
131 | parsed = json.loads(body) | |
119 | if parsed.get(r'error_code'): |
|
132 | if parsed.get(r'error_code'): |
General Comments 0
You need to be logged in to leave comments.
Login now