Show More
@@ -48,6 +48,7 b' class SimpleSvnApp(object):' | |||||
48 |
|
48 | |||
49 | def __init__(self, config): |
|
49 | def __init__(self, config): | |
50 | self.config = config |
|
50 | self.config = config | |
|
51 | self.session = requests.Session() | |||
51 |
|
52 | |||
52 | def __call__(self, environ, start_response): |
|
53 | def __call__(self, environ, start_response): | |
53 | request_headers = self._get_request_headers(environ) |
|
54 | request_headers = self._get_request_headers(environ) | |
@@ -94,10 +95,17 b' class SimpleSvnApp(object):' | |||||
94 | log.debug('Calling SVN PROXY at `%s`, using method:%s. Stream: %s', |
|
95 | log.debug('Calling SVN PROXY at `%s`, using method:%s. Stream: %s', | |
95 | path_info, req_method, stream) |
|
96 | path_info, req_method, stream) | |
96 |
|
97 | |||
|
98 | call_kwargs = dict( | |||
|
99 | data=data_io, | |||
|
100 | headers=request_headers, | |||
|
101 | stream=stream | |||
|
102 | ) | |||
|
103 | if req_method in ['HEAD', 'DELETE']: | |||
|
104 | del call_kwargs['data'] | |||
|
105 | ||||
97 | try: |
|
106 | try: | |
98 |
response = |
|
107 | response = self.session.request( | |
99 | req_method, path_info, |
|
108 | req_method, path_info, **call_kwargs) | |
100 | data=data_io, headers=request_headers, stream=stream) |
|
|||
101 | except requests.ConnectionError: |
|
109 | except requests.ConnectionError: | |
102 | log.exception('ConnectionError occurred for endpoint %s', path_info) |
|
110 | log.exception('ConnectionError occurred for endpoint %s', path_info) | |
103 | raise |
|
111 | raise |
@@ -63,11 +63,12 b' from rhodecode.model.settings import Set' | |||||
63 | log = logging.getLogger(__name__) |
|
63 | log = logging.getLogger(__name__) | |
64 |
|
64 | |||
65 |
|
65 | |||
66 | def extract_svn_txn_id(acl_repo_name, data): |
|
66 | def extract_svn_txn_id(acl_repo_name, data: bytes): | |
67 | """ |
|
67 | """ | |
68 | Helper method for extraction of svn txn_id from submitted XML data during |
|
68 | Helper method for extraction of svn txn_id from submitted XML data during | |
69 | POST operations |
|
69 | POST operations | |
70 | """ |
|
70 | """ | |
|
71 | ||||
71 | try: |
|
72 | try: | |
72 | root = etree.fromstring(data) |
|
73 | root = etree.fromstring(data) | |
73 | pat = re.compile(r'/txn/(?P<txn_id>.*)') |
|
74 | pat = re.compile(r'/txn/(?P<txn_id>.*)') | |
@@ -609,13 +610,13 b' class SimpleVCS(object):' | |||||
609 | stream = environ['wsgi.input'] |
|
610 | stream = environ['wsgi.input'] | |
610 |
|
611 | |||
611 | if isinstance(stream, io.BytesIO): |
|
612 | if isinstance(stream, io.BytesIO): | |
612 |
data: |
|
613 | data: bytes = stream.getvalue() | |
613 | elif hasattr(stream, 'buf'): # most likely gunicorn.http.body.Body |
|
614 | elif hasattr(stream, 'buf'): # most likely gunicorn.http.body.Body | |
614 |
data: |
|
615 | data: bytes = stream.buf.getvalue() | |
615 | else: |
|
616 | else: | |
616 | # fallback to the crudest way, copy the iterator |
|
617 | # fallback to the crudest way, copy the iterator | |
617 |
data = safe_ |
|
618 | data = safe_bytes(stream.read()) | |
618 |
environ['wsgi.input'] = io.BytesIO( |
|
619 | environ['wsgi.input'] = io.BytesIO(data) | |
619 |
|
620 | |||
620 | txn_id = extract_svn_txn_id(self.acl_repo_name, data) |
|
621 | txn_id = extract_svn_txn_id(self.acl_repo_name, data) | |
621 |
|
622 |
@@ -84,10 +84,12 b' def is_svn(environ):' | |||||
84 | magic_path_segment = rhodecode.CONFIG.get( |
|
84 | magic_path_segment = rhodecode.CONFIG.get( | |
85 | 'rhodecode_subversion_magic_path', '/!svn') |
|
85 | 'rhodecode_subversion_magic_path', '/!svn') | |
86 | path_info = get_path_info(environ) |
|
86 | path_info = get_path_info(environ) | |
|
87 | req_method = environ['REQUEST_METHOD'] | |||
|
88 | ||||
87 | is_svn_path = ( |
|
89 | is_svn_path = ( | |
88 | 'subversion' in http_dav or |
|
90 | 'subversion' in http_dav or | |
89 | magic_path_segment in path_info |
|
91 | magic_path_segment in path_info | |
90 |
or |
|
92 | or req_method in ['PROPFIND', 'PROPPATCH', 'HEAD'] | |
91 | ) |
|
93 | ) | |
92 | log.debug( |
|
94 | log.debug( | |
93 | 'request path: `%s` detected as SVN PROTOCOL %s', path_info, |
|
95 | 'request path: `%s` detected as SVN PROTOCOL %s', path_info, | |
@@ -187,6 +189,7 b' def detect_vcs_request(environ, backends' | |||||
187 | ] |
|
189 | ] | |
188 | path_info = get_path_info(environ) |
|
190 | path_info = get_path_info(environ) | |
189 | path_url = path_info.lstrip('/') |
|
191 | path_url = path_info.lstrip('/') | |
|
192 | req_method = environ.get('REQUEST_METHOD') | |||
190 |
|
193 | |||
191 | for item in white_list: |
|
194 | for item in white_list: | |
192 | if item.endswith('++') and path_url.startswith(item[:-2]): |
|
195 | if item.endswith('++') and path_url.startswith(item[:-2]): | |
@@ -210,7 +213,8 b' def detect_vcs_request(environ, backends' | |||||
210 | log.debug('got handler:%s from environ', handler) |
|
213 | log.debug('got handler:%s from environ', handler) | |
211 |
|
214 | |||
212 | if not handler: |
|
215 | if not handler: | |
213 |
log.debug('request start: checking if request for `%s` is of VCS type in order: %s', |
|
216 | log.debug('request start: checking if request for `%s:%s` is of VCS type in order: %s', | |
|
217 | req_method, path_url, backends) | |||
214 | for vcs_type in backends: |
|
218 | for vcs_type in backends: | |
215 | vcs_check, _handler = checks[vcs_type] |
|
219 | vcs_check, _handler = checks[vcs_type] | |
216 | if vcs_check(environ): |
|
220 | if vcs_check(environ): |
General Comments 0
You need to be logged in to leave comments.
Login now