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

Binary content does not POST. 408 error returned. #565

Closed
acurrieebix opened this issue Jun 15, 2022 · 6 comments · Fixed by #572
Closed

Binary content does not POST. 408 error returned. #565

acurrieebix opened this issue Jun 15, 2022 · 6 comments · Fixed by #572
Assignees
Labels
bug Something isn't working

Comments

@acurrieebix
Copy link

acurrieebix commented Jun 15, 2022

Passing a binary content will return 408 from the endpoint after a long wait.

To Reproduce

The following code will return a 408 from the service

var credentials = new ImmutableCredentials("AKIA2WNEXAMPLE", "rObND507EXAMPLE", null);

var client = new HttpClient();

byte[] fileBytes = File.ReadAllBytes(@"C:\File.pdf");
MemoryStream destination = new MemoryStream(fileBytes);
destination.Seek(0, SeekOrigin.Begin);

HttpContent content = new StreamContent(destination);

content.Headers.Add("x-api-key", "apikey");

var response = await client.PostAsync(
  "https://uat-customamazonservice.domain.net/v2/extract?inpFormat=PDF",
  content: content,
  regionName: "us-east-1",
  serviceName: "execute-api",
  credentials: credentials);

Checking web debugging tool (e.g. fiddler) you can see the content of the request is empty.

Expected behavior

The request should be sent and processed.

Desktop (please complete the following information):

Windows 11 .net 6 console client.

Additional context

If you send base64 encoded StringContent rather than StreamContent, the request is successful.

The fix is to reset the stream back to the beginning. I suggest doing this when the content hash is created by adding the following at line 30 in ContentHashcs.

contentStream.Seek(0, System.IO.SeekOrigin.Begin);
@acurrieebix acurrieebix added the bug Something isn't working label Jun 15, 2022
@github-actions
Copy link
Contributor

Hi there and welcome to this repository!

A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it.

@FantasticFiasco
Copy link
Owner

Hi @acurrieebix!

Thank you for your detailed explanation. Let me see if I can reproduce it and fix the problem.

@FantasticFiasco
Copy link
Owner

I was able to reproduce the problem. Will continue to apply the fix.

@FantasticFiasco
Copy link
Owner

I've published a new version here. Could you please verify that it is solving your problem?

Again, thanks for the issue description. It was spot on, and thus an easy issue to fix.

@FantasticFiasco
Copy link
Owner

An official version has been release on nuget.org.

@acurrieebix
Copy link
Author

acurrieebix commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants