Skip to content

Enhance handling of text response - support more text minetypes and subtypes.#1023

Closed
cobnett3 wants to merge 1 commit into
zappa:masterfrom
cobnett3:feature/enhance-handling-of-text-response
Closed

Enhance handling of text response - support more text minetypes and subtypes.#1023
cobnett3 wants to merge 1 commit into
zappa:masterfrom
cobnett3:feature/enhance-handling-of-text-response

Conversation

@cobnett3

Copy link
Copy Markdown

Description

Currently, minetypes starts with "text/" and "application/json" are handled as text responses from the WSGI server.
However, there are more minetypes that should be returned as text, not binary.

This PR adds support for the following minetypes to be treated as text.

  • RFC 4627 (currently supported)
    • application/json
  • RFC 4329 (by this PR)
    • application/javascript
    • application/ecmascript
  • RFC 3023 (by this PR)
    • application/xml
    • application/xml-external-parsed-entity
    • application/xml-dtd
    • image/svg+xml
    • specified by pattern "application/*+xml" including (but not limited to):
      • application/mathml+xml
      • application/xslt+xml
      • application/rdf+xml
      • application/atom+xml (ref: RFC 5023)
      • application/atomcat+xml (ref: RFC 5023)
      • application/atomsvc+xml (ref: RFC 5023)
      • application/beep+xml (ref: RFC 3080)
      • application/rss+xml
      • application/vnd.google-earth.kml+xml
      • application/vnd.irepository.package+xml
      • application/vnd.mozilla.xul+xml
      • application/vnd.pwg-xhtml-print+xml  
      • application/xaml+xml
      • application/xhtml+xml

GitHub Issues

#1021

@cobnett3 cobnett3 force-pushed the feature/enhance-handling-of-text-response branch from 2d87d00 to 7ac1c45 Compare September 19, 2021 03:29
@ghostmaster-ai

Copy link
Copy Markdown

Pease make the same pull request on Zappa2, which is a branch of this repo. Since This repo has been deprecated I will take up maintenance.
PyPi - pip install zappa2

@cobnett3

cobnett3 commented Jan 1, 2022

Copy link
Copy Markdown
Author

Considering the latest update regarding the maintainers of this project, is this still valid to keep this PR here?

monkut added a commit that referenced this pull request Aug 12, 2022
♻️ define "DEFAULT_TEXT_MIMETYPES" and move to utilities.py
@monkut

monkut commented Aug 12, 2022

Copy link
Copy Markdown
Collaborator

Integrating partially into:
#1155

closing.

@monkut monkut closed this Aug 12, 2022
monkut added a commit that referenced this pull request Nov 11, 2022
…ata is binary (#1155)

* 🔧 migrate #971 to lastest master

* 🎨 run black/isort

* ♻️ refactor to allow for other binary ignore types based on mimetype. (currently openapi schema can't be passed as text.

* 🎨 run black/fix flake8

* 🔧 add EXCEPTION_HANDLER setting

* 🐛 fix zappa_returndict["body"] assignment

* 📝 add temp debug info

* 🔥 delete unnecessary print statements

* ♻️ Update comments and minor refactor for clarity

* ♻️ refactor for ease of testing and clarity

* 🎨 fix flake8

* ✨ add `additional_text_mimetypes` setting
✅ add testcases for additional_text_mimetypes handling

* 🔧 Expand default text mimetypes mentioned in #1023
♻️ define "DEFAULT_TEXT_MIMETYPES" and move to utilities.py

* 🎨 run black/isort

* 🎨 run black/isort

* 🎨 remove unnecesasry comment (black now reformats code)
🎨 change commented lines to docstring for test app
Ian288 pushed a commit to tackle-io/Zappa that referenced this pull request Jul 11, 2023
… if data is binary (zappa#1155)

* 🔧 migrate zappa#971 to lastest master

* 🎨 run black/isort

* ♻️ refactor to allow for other binary ignore types based on mimetype. (currently openapi schema can't be passed as text.

* 🎨 run black/fix flake8

* 🔧 add EXCEPTION_HANDLER setting

* 🐛 fix zappa_returndict["body"] assignment

* 📝 add temp debug info

* 🔥 delete unnecessary print statements

* ♻️ Update comments and minor refactor for clarity

* ♻️ refactor for ease of testing and clarity

* 🎨 fix flake8

* ✨ add `additional_text_mimetypes` setting
✅ add testcases for additional_text_mimetypes handling

* 🔧 Expand default text mimetypes mentioned in zappa#1023
♻️ define "DEFAULT_TEXT_MIMETYPES" and move to utilities.py

* 🎨 run black/isort

* 🎨 run black/isort

* 🎨 remove unnecesasry comment (black now reformats code)
🎨 change commented lines to docstring for test app
monkut added a commit that referenced this pull request May 20, 2025
* 🔧 migrate #971 to lastest master

* 🎨 run black/isort

* ♻️ refactor to allow for other binary ignore types based on mimetype. (currently openapi schema can't be passed as text.

* 🎨 run black/fix flake8

* 🔧 add EXCEPTION_HANDLER setting

* 🐛 fix zappa_returndict["body"] assignment

* 📝 add temp debug info

* 🔥 delete unnecessary print statements

* ♻️ Update comments and minor refactor for clarity

* ♻️ refactor for ease of testing and clarity

* 🎨 fix flake8

* ✨ add `additional_text_mimetypes` setting
✅ add testcases for additional_text_mimetypes handling

* 🔧 Expand default text mimetypes mentioned in #1023
♻️ define "DEFAULT_TEXT_MIMETYPES" and move to utilities.py

* 🎨 run black/isort

* 🎨 run black/isort

* feat: implement handler for event with format  version 2.0

* refactor: getting processed response body from new method

* fix: lint error

* chore: move variable initialization before initial if condition

* refactor: abstract implementations to two processing methods

* fix: determine payload version based on value in the event itself

* fixed lint

---------

Co-authored-by: monkut <shane.cousins@gmail.com>
Co-authored-by: Rehan Hawari <rehan.hawari10@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants