Allow usage of "Accept" header on iOS #130
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On iOS, the accepted content-types of the http response are hard-coded in TextResponseSerializer, which makes impossible to customize them without forking the repo.
This commit adds the possibility to extend the Set of the acceptableContentTypes, using the Accept header from the http request. So, any content-type(s) sent in that header will be added to the accepted ones. Without this change, the Accept header would be working as expected on Android, but not on iOS, creating a risky inconsistency.
The fastest way I found to get this done was to pass the header Dictionary to the TextResponseSerializer serializer method, but maybe somebody has a cleaner way to do the same, please have a look.
Warning: just as a reminder, since this code changes the +serializer signature, if new methods are added to CordovaHttpPlugin implementation (e.g with the PR#105), calls to serializer needs to be adapted.