Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

cannot overwrite default request headers on ios #261

@katonap

Description

@katonap

We use capacitor and this http plugin in an angular application. The Accept-Language header is set on the request (Http.request()), but when it is sent to the server we see additional languages in this header, not just the one we set.

I found that CapacitorUrlRequest initializes the Accept-Language header based on some device settings. Later when setRequestHeaders() is called it appends the parameter headers to the existing ones, not overwrites them. This means that the parameter language for the Accept-Language header will be the last language in the header, and because the first one has a quality value of 1 (as the default), our language can never have a higher priority than that.
I beleive calling request.setValue() instead of the current request.addValue() would solve this problem. URLRequest docs

As an additional info the java code for android overwrites the headers in CapacitorHttpUrlConnection.setRequestHeaders().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions