|
2 | 2 | import requests |
3 | 3 | import os |
4 | 4 | import sys |
5 | | -import json |
6 | 5 | import traceback |
7 | 6 | import logging |
8 | 7 | import ssl |
9 | 8 | from flask_cors import CORS |
10 | 9 | from requests.structures import CaseInsensitiveDict |
11 | 10 | from requests.models import Response, Request |
12 | | -from six import iteritems, string_types |
| 11 | +from six import iteritems |
13 | 12 | from six.moves.socketserver import ThreadingMixIn |
14 | 13 | from six.moves.urllib.parse import urlparse |
15 | | -from localstack.config import DEFAULT_ENCODING, TMP_FOLDER, USE_SSL |
| 14 | +from localstack.config import TMP_FOLDER, USE_SSL |
16 | 15 | from localstack.constants import ENV_INTERNAL_TEST_RUN |
17 | 16 | from localstack.utils.common import FuncThread, generate_ssl_cert, to_bytes |
18 | 17 |
|
@@ -144,16 +143,7 @@ def forward(self, method): |
144 | 143 | target_url = self.path |
145 | 144 | if '://' not in target_url: |
146 | 145 | target_url = '%s%s' % (self.proxy.forward_url, target_url) |
147 | | - data = None |
148 | | - if method in ['POST', 'PUT', 'PATCH']: |
149 | | - data_string = self.data_bytes |
150 | | - try: |
151 | | - if not isinstance(data_string, string_types): |
152 | | - data_string = data_string.decode(DEFAULT_ENCODING) |
153 | | - data = json.loads(data_string) |
154 | | - except Exception as e: |
155 | | - # unable to parse JSON, fallback to verbatim string/bytes |
156 | | - data = data_string |
| 146 | + data = self.data_bytes |
157 | 147 |
|
158 | 148 | forward_headers = CaseInsensitiveDict(self.headers) |
159 | 149 | # update original "Host" header (moto s3 relies on this behavior) |
@@ -181,6 +171,7 @@ def forward(self, method): |
181 | 171 | self.send_response(code) |
182 | 172 | self.end_headers() |
183 | 173 | return |
| 174 | + # perform the actual invocation of the backend service |
184 | 175 | if response is None: |
185 | 176 | if modified_request: |
186 | 177 | response = self.method(proxy_url, data=modified_request.data, |
|
0 commit comments