|
| 1 | +diff --git a/rest.py b/restpatch.py |
| 2 | +index b8da0751..3702266e 100644 |
| 3 | +--- a/rest.py |
| 4 | ++++ b/restpatch.py |
| 5 | +@@ -61,6 +61,10 @@ class RESTClientObject(object): |
| 6 | + else: |
| 7 | + cert_reqs = ssl.CERT_NONE |
| 8 | + |
| 9 | ++ # VRChatAPI: Init global cookie storage |
| 10 | ++ from http.cookiejar import CookieJar |
| 11 | ++ self.cookie_jar = CookieJar() |
| 12 | ++ |
| 13 | + addition_pool_args = {} |
| 14 | + if configuration.assert_hostname is not None: |
| 15 | + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 |
| 16 | +@@ -134,6 +138,13 @@ class RESTClientObject(object): |
| 17 | + post_params = post_params or {} |
| 18 | + headers = headers or {} |
| 19 | + |
| 20 | ++ # VRChatAPI: Build a mock Request object to work with |
| 21 | ++ from urllib.request import Request |
| 22 | ++ mock_request_object = Request(url=url, method=method, headers=headers) |
| 23 | ++ self.cookie_jar.add_cookie_header(mock_request_object) |
| 24 | ++ if "Cookie" in mock_request_object.unredirected_hdrs: |
| 25 | ++ headers["Cookie"] = mock_request_object.unredirected_hdrs["Cookie"] |
| 26 | ++ |
| 27 | + timeout = None |
| 28 | + if _request_timeout: |
| 29 | + if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821 |
| 30 | +@@ -209,6 +220,10 @@ class RESTClientObject(object): |
| 31 | + msg = "{0}\n{1}".format(type(e).__name__, str(e)) |
| 32 | + raise ApiException(status=0, reason=msg) |
| 33 | + |
| 34 | ++ |
| 35 | ++ # VRChatAPI: Extract and save cookies for global storage |
| 36 | ++ self.cookie_jar.extract_cookies(r, mock_request_object) |
| 37 | ++ |
| 38 | + if _preload_content: |
| 39 | + r = RESTResponse(r) |
| 40 | + |
0 commit comments