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

FlurlRequest SendAsync adds an extra space to Content-Type #740

Closed
AeonLucid opened this issue Jan 16, 2023 · 2 comments
Closed

FlurlRequest SendAsync adds an extra space to Content-Type #740

AeonLucid opened this issue Jan 16, 2023 · 2 comments

Comments

@AeonLucid
Copy link
Contributor

Note, I am currently using the master-3.x branch.

SyncHeaders(request);
var call = new FlurlCall {
Request = this,
RedirectedFrom = _redirectedFrom,
HttpRequestMessage = request
};
request.SetFlurlCall(call);
await RaiseEventAsync(Settings.BeforeCall, Settings.BeforeCallAsync, call).ConfigureAwait(false);
// in case URL or headers were modified in the handler above
request.RequestUri = Url.ToUri();
SyncHeaders(request);

When you send a HTTP POST request with the following content.

internal class CustomMediaType : MediaTypeHeaderValue
{
    public CustomMediaType() : base("application/octet-stream")
    {
    }

    public override string ToString()
    {
        return "application/octet-stream;some=b";
    }
}
new ByteArrayContent(reqBody)
{
    Headers =
    {
        ContentType = new CustomMediaType()
    }
})

What happens is, at the first SyncHeaders call it is copied from request.Content.Headers into the Headers property. This is all still fine.
Then on the second call of SyncHeaders, it copies from Headers back into request.Content through request.SetHeader, which causes it to normalize the header.

The value application/octet-stream;some=b becomes application/octet-stream; some=b, after the second SyncHeaders call.

I understand this might be a slight edge case but as you can see similar issues have been raised with the .NET team. dotnet/runtime#30171

@AeonLucid AeonLucid added the bug label Jan 16, 2023
@tmenier
Copy link
Owner

tmenier commented Mar 16, 2023

Sorry for the delay. Thanks for the details, if I understand it correctly this might be fixable.

@tmenier tmenier added this to Backlog in Default Project via automation Mar 16, 2023
@tmenier tmenier added the 4.0 label Sep 19, 2023
@tmenier tmenier moved this from Backlog to In Progress in Default Project Sep 19, 2023
tmenier pushed a commit that referenced this issue Sep 19, 2023
@tmenier
Copy link
Owner

tmenier commented Sep 19, 2023

Fixed for 4.0

@tmenier tmenier moved this from In Progress to Ready in Default Project Sep 19, 2023
@tmenier tmenier moved this from Ready to In Prerelease in Default Project Oct 9, 2023
@tmenier tmenier moved this from In Prerelease to Released in Default Project Dec 14, 2023
@tmenier tmenier closed this as completed Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Default Project
  
Released
Development

No branches or pull requests

2 participants