Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Content Headers in requests #163

Closed
HoraceGonzalez opened this issue Sep 19, 2019 · 2 comments
Closed

Setting Content Headers in requests #163

HoraceGonzalez opened this issue Sep 19, 2019 · 2 comments

Comments

@HoraceGonzalez
Copy link
Contributor

HoraceGonzalez commented Sep 19, 2019

This is more of a question about a potential change I'd like to make than an issue. While using Http.fs to connect to Amazon's new product advertising API, I ran into a road-block around setting one of the request headers. Their API requires a Content-Encoding header to be set on the request (who does this?). Anyway, since this is technically a "content header", it's not possible to set it this way:

|> Request.setHeader (Custom ("Content-Encoding", "amz-1.0"))

The underlying .net HttpRequestHeaders just isn't having any of these shenanigans, and will refuse to add the header.

I tried working around the issue by adding it as a default header on the HttpClient instance, but since it's content header, it needs to be set on the content of an actual request.

I attempted a temporary work-around in my own fork of Http.fs that I'm not particularly satisfied with: HoraceGonzalez@b2ea9d8#diff-f07862fe9695509b6f1d49af7970ec28R695

It applies to all Custom headers that start with the string "Content-". I feel like this could be a potentially breaking API change or at least cause some unintended problems for people.

Perhaps I could add a new RequestHeader.ContentEncoding value to the DU that functions similarly to the ContentType header? It's not technically a request header, but it's consistent with the way the API handles the other content headers.

Any thoughts, @haf?

@haf
Copy link
Owner

haf commented Sep 19, 2019

I think it's an "entity header" and like you say, could be a RequestHeader value, alike Content-Type. Go ahead and add it there.

@HoraceGonzalez
Copy link
Contributor Author

Perfect. I'll send over a PR.

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

No branches or pull requests

2 participants