Show More
@@ -22,18 +22,19 b'' | |||
|
22 | 22 | Various version Control System version lib (vcs) management abstraction layer |
|
23 | 23 | for Python. Build with server client architecture. |
|
24 | 24 | """ |
|
25 | import io | |
|
25 | 26 | import atexit |
|
26 | 27 | import logging |
|
27 | from io import StringIO | |
|
28 | 28 | |
|
29 | 29 | import rhodecode |
|
30 | from rhodecode.lib.str_utils import safe_bytes | |
|
30 | 31 | from rhodecode.lib.vcs.conf import settings |
|
31 | 32 | from rhodecode.lib.vcs.backends import get_vcs_instance, get_backend |
|
32 | 33 | from rhodecode.lib.vcs.exceptions import ( |
|
33 | 34 | VCSError, RepositoryError, CommitError, VCSCommunicationError) |
|
34 | 35 | |
|
35 | 36 | __all__ = [ |
|
36 |
|
|
|
37 | 'get_vcs_instance', 'get_backend', | |
|
37 | 38 | 'VCSError', 'RepositoryError', 'CommitError', 'VCSCommunicationError' |
|
38 | 39 | ] |
|
39 | 40 | |
@@ -54,14 +55,9 b' except ImportError:' | |||
|
54 | 55 | import pycurl |
|
55 | 56 | |
|
56 | 57 | |
|
57 | def get_version(): | |
|
58 | """ | |
|
59 | Returns shorter version (digit parts only) as string. | |
|
60 | """ | |
|
61 | return '.'.join((str(each) for each in VERSION[:3])) | |
|
58 | def connect_http(server_and_port): | |
|
59 | log.debug('Initialized VCSServer connections to %s.', server_and_port) | |
|
62 | 60 | |
|
63 | ||
|
64 | def connect_http(server_and_port): | |
|
65 | 61 | from rhodecode.lib.vcs import connection, client_http |
|
66 | 62 | from rhodecode.lib.middleware.utils import scm_app |
|
67 | 63 | |
@@ -113,6 +109,7 b' class CurlSession(object):' | |||
|
113 | 109 | Please have a look at the class :class:`requests.Session` when you extend |
|
114 | 110 | it. |
|
115 | 111 | """ |
|
112 | CURL_UA = f'RhodeCode HTTP {rhodecode.__version__}' | |
|
116 | 113 | |
|
117 | 114 | def __init__(self): |
|
118 | 115 | curl = pycurl.Curl() |
@@ -122,7 +119,7 b' class CurlSession(object):' | |||
|
122 | 119 | |
|
123 | 120 | curl.setopt(curl.TCP_NODELAY, True) |
|
124 | 121 | curl.setopt(curl.PROTOCOLS, curl.PROTO_HTTP) |
|
125 | curl.setopt(curl.USERAGENT, 'RhodeCode HTTP {}'.format(rhodecode.__version__)) | |
|
122 | curl.setopt(curl.USERAGENT, safe_bytes(self.CURL_UA)) | |
|
126 | 123 | curl.setopt(curl.SSL_VERIFYPEER, 0) |
|
127 | 124 | curl.setopt(curl.SSL_VERIFYHOST, 0) |
|
128 | 125 | self._curl = curl |
@@ -130,8 +127,8 b' class CurlSession(object):' | |||
|
130 | 127 | def post(self, url, data, allow_redirects=False, headers=None): |
|
131 | 128 | headers = headers or {} |
|
132 | 129 | # format is ['header_name1: header_value1', 'header_name2: header_value2']) |
|
133 | headers_list = ["Expect:"] + ['{}: {}'.format(k, v) for k, v in headers.items()] | |
|
134 |
response_buffer = |
|
|
130 | headers_list = [b"Expect:"] + [safe_bytes('{}: {}'.format(k, v)) for k, v in headers.items()] | |
|
131 | response_buffer = io.BytesIO() | |
|
135 | 132 | |
|
136 | 133 | curl = self._curl |
|
137 | 134 | curl.setopt(curl.URL, url) |
General Comments 0
You need to be logged in to leave comments.
Login now