-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
232 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
API_STAGE = "dev" | ||
APP_FUNCTION = "app" | ||
APP_MODULE = "tests.test_wsgi_binary_support_app" | ||
BINARY_SUPPORT = True | ||
CONTEXT_HEADER_MAPPINGS = {} | ||
DEBUG = "True" | ||
DJANGO_SETTINGS = None | ||
DOMAIN = "api.example.com" | ||
ENVIRONMENT_VARIABLES = {} | ||
LOG_LEVEL = "DEBUG" | ||
PROJECT_NAME = "binary_support_settings" | ||
COGNITO_TRIGGER_MAPPING = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
### | ||
# This test application exists to confirm how Zappa handles WSGI application | ||
# _responses_ when Binary Support is enabled. | ||
### | ||
|
||
import gzip | ||
import json | ||
|
||
from flask import Flask, Response, send_file | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/textplain_mimetype_response1", methods=["GET"]) | ||
def text_mimetype_response_1(): | ||
return Response(response="OK", mimetype="text/plain") | ||
|
||
|
||
@app.route("/textarbitrary_mimetype_response1", methods=["GET"]) | ||
def text_mimetype_response_2(): | ||
return Response(response="OK", mimetype="text/arbitary") | ||
|
||
|
||
@app.route("/json_mimetype_response1", methods=["GET"]) | ||
def json_mimetype_response_1(): | ||
return Response(response=json.dumps({"some": "data"}), mimetype="application/json") | ||
|
||
|
||
@app.route("/arbitrarybinary_mimetype_response1", methods=["GET"]) | ||
def arbitrary_mimetype_response_1(): | ||
return Response(response=b"some binary data", mimetype="arbitrary/binary_mimetype") | ||
|
||
|
||
@app.route("/arbitrarybinary_mimetype_response2", methods=["GET"]) | ||
def arbitrary_mimetype_response_3(): | ||
return Response(response="doesnt_matter", mimetype="definitely_not_text") | ||
|
||
|
||
@app.route("/content_encoding_header_json1", methods=["GET"]) | ||
def response_with_content_encoding_1(): | ||
return Response( | ||
response=gzip.compress(json.dumps({"some": "data"}).encode()), | ||
mimetype="application/json", | ||
headers={"Content-Encoding": "gzip"}, | ||
) | ||
|
||
|
||
@app.route("/content_encoding_header_textarbitrary1", methods=["GET"]) | ||
def response_with_content_encoding_2(): | ||
return Response( | ||
response=b"OK", | ||
mimetype="text/arbitrary", | ||
headers={"Content-Encoding": "something_arbitrarily_binary"}, | ||
) | ||
|
||
|
||
@app.route("/content_encoding_header_textarbitrary2", methods=["GET"]) | ||
def response_with_content_encoding_3(): | ||
return Response( | ||
response="OK", | ||
mimetype="text/arbitrary", | ||
headers={"Content-Encoding": "with_content_type_but_not_bytes_response"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters