DRF URL Content Type Override
DRF URL Content Type Override allows the content type of the request to be overriden with a url parameter.
Why would I need this?
Sometimes it makes sense to override the content type specified in the header. For example, some browser’s XHR, such as IE9, are unable to support CORS. Pollyfills like, jQuery-ajaxTransport-XDomainRequest or httpplease’s oldiexdomain.js plug-in get around this by using XDomainRequest, which supports CORS. The problem is XDomainRequest only sends a content type of text/plain in the header. This is problematic when POSTing form data. DRF URL Content Type Override let’s you specify a content type which will override the header value.
Install
pip install drf-url-content-type-override
Add ‘DEFAULT_CONTENT_NEGOTIATION_CLASS’
REST_FRAMEWORK = {
'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'drf_url_content_type_override.URLOverrideContentNegotiation',
}
Usage
Example: Javascript on a different domain from the API.
jquery.ajax({
'url': 'http://apidomain.com/api/1/contact?_content_type=application/x-www-form-urlencoded',
'type': 'POST',
'data': {'name': 'Chris'}
})
For more background see https://github.com/tomchristie/django-rest-framework/pull/1731
Metadata
Release files for drf-url-content-type-override 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drf-url-content-type-override-1.0.0.tar.gz | 3.4 kB | Without provenance | Details for drf-url-content-type-override-1.0.0.tar.gz |
Release files / drf-url-content-type-override-1.0.0.tar.gz
| Download URL | drf-url-content-type-override-1.0.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a95acba1690587180205454f5b3d8a15613cec64b51c8e507c3cbdc06d47f701
|
|
BLAKE2b-256 checksum How to use checksums |
e33f1045c170917032fda04cfdbb47a02749baf59b1714d4e9db6c13978b9f2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for drf-url-content-type-override 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.