Skip to content

Commit

Permalink
fix encoding headers for invocation responses
Browse files Browse the repository at this point in the history
  • Loading branch information
whummer committed Nov 23, 2024
1 parent 1ab5d6b commit 8795c7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions miniflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Hello World!

## Change Log

* `0.1.2`: Pin wrangler version to fix hanging miniflare invocations; fix encoding headers for invocation responses
* `0.1.1`: Adapt for LocalStack v3.0
* `0.1.0`: Upgrade to Miniflare 3.0
* `0.0.1`: Initial version.
Expand Down
10 changes: 8 additions & 2 deletions miniflare/miniflare/cloudflare_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ def handle_invocation(request: Request, path: str, script_name: str, port: str):
port = SCRIPT_SERVERS[script_name].port
response = requests.request(
method=request.method,
url=f"http://localhost:{port}{request.path}",
url=f"http://localhost:{port}/{path}",
data=request.get_data(),
)
result = Response()
result.status_code = response.status_code
result.set_data(response.content)
result.headers.update(dict(response.headers))
headers = dict(response.headers)
if headers.get('Transfer-Encoding') == 'chunked':
headers.pop('Transfer-Encoding')
if headers.get('Content-Encoding') == 'gzip':
headers.pop('Content-Encoding')
LOG.debug("Miniflare invocation response headers/body: %s / %s", headers, response.content)
result.headers.update(headers)
return result


Expand Down
2 changes: 1 addition & 1 deletion miniflare/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = localstack-extension-miniflare
version = 0.1.2
version = 0.1.3
summary = LocalStack Extension: Miniflare
description = This extension makes Miniflare (dev environment for Cloudflare workers) available directly in LocalStack
long_description = file: README.md
Expand Down

0 comments on commit 8795c7e

Please sign in to comment.