Skip to content

Can we add a Content-Type header to dbForm requests? #142

@davidqc

Description

@davidqc

Any HTTP/1.1 message containing an entity-body SHOULD include a
Content-Type header field defining the media type of that body. If
and only if the media type is not given by a Content-Type field, the
recipient MAY attempt to guess the media type via inspection of its
content and/or the name extension(s) of the URI used to identify the
resource. If the media type remains unknown, the recipient SHOULD
treat it as type "application/octet-stream".


SHOULD: This word, or the adjective "RECOMMENDED", mean that there
may exist valid reasons in particular circumstances to ignore a
particular item, but the full implications must be understood and
carefully weighed before choosing a different course.


I guess it would be done either in the caller:
https://github.com/qcode-software/qcode-ui/blob/master/js/jquery.dbForm.js#L36

                headers: {
                    Accept: "application/json,text/xml"
                }

or checked and added in httpPost

headers = $.extend({'X-Authenticity-Token': Cookies.get('authenticity_token')}, headers);

function httpPost(url,data,handler,errorHandler,async,headers) {
    // Add event listener to check whether request is cancelled by navigation
    var unloading = false;
    headers = $.extend({'X-Authenticity-Token': Cookies.get('authenticity_token')}, headers);
``

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions