|
12 | 12 | from ravendb.http.http_cache import HttpCache |
13 | 13 | from ravendb.http.misc import ResponseDisposeHandling |
14 | 14 | from ravendb.http.server_node import ServerNode |
| 15 | +from ravendb.util.request_utils import RequestUtils |
15 | 16 |
|
16 | 17 |
|
17 | 18 | class RavenCommandResponseType(Enum): |
@@ -98,25 +99,9 @@ def set_response(self, response: Optional[str], from_cache: bool) -> None: |
98 | 99 |
|
99 | 100 | def send(self, session: requests.Session, request: requests.Request) -> requests.Response: |
100 | 101 | prepared_request = session.prepare_request(request) |
101 | | - self._remove_zstd_encoding(prepared_request) |
| 102 | + RequestUtils.remove_zstd_encoding(prepared_request) |
102 | 103 | return session.send(prepared_request, cert=session.cert) |
103 | 104 |
|
104 | | - # https://issues.hibernatingrhinos.com/issue/RDBC-940 |
105 | | - # If user has installed module 'zstd' or 'zstandard', |
106 | | - # 'requests' module will automatically add 'zstd' to 'Accept-Encoding' header. |
107 | | - # This causes exceptions. Excluding 'zstd' from the header in this workaround, |
108 | | - # while we keep investigating cause of the issue. |
109 | | - @staticmethod |
110 | | - def _remove_zstd_encoding(request: requests.PreparedRequest) -> None: |
111 | | - accept_encoding = request.headers.get("Accept-Encoding") |
112 | | - |
113 | | - if "zstd" in accept_encoding: |
114 | | - encodings = [ |
115 | | - encoding.strip() for encoding in accept_encoding.split(",") if encoding.strip().lower() != "zstd" |
116 | | - ] |
117 | | - new_header_value = ", ".join(encodings) |
118 | | - request.headers["Accept-Encoding"] = new_header_value |
119 | | - |
120 | 105 | def set_response_raw(self, response: requests.Response, stream: bytes) -> None: |
121 | 106 | raise RuntimeError( |
122 | 107 | f"When {self.response_type} is set to Raw then please override this method to handle the response " |
|
0 commit comments