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

POST Request Adding Unexpected Chunked Encoding in Fetch API: Send Full Content-Length according to headers #104

Closed
PratikBodawala opened this issue Aug 26, 2024 · 0 comments · Fixed by #105
Assignees
Labels
bug Something isn't working

Comments

@PratikBodawala
Copy link
Contributor

I’m encountering a problem with chunked encoding when making a POST request using the Fetch API. Here’s a snippet of my code:

const resp = await fetch(
    'https://backend.ngrok-free.app/api/location/location',
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: '{"foo": "bar"}',
    },
);

The request is being sent with chunked encoding, which adds 1 or 2 hex characters before the JSON data and a 0 after it. The request details are:

Host: backend.ngrok-free.app
User-Agent: Dalvik/2.1.0 (Linux; U; Android 14)
Transfer-Encoding: chunked
Accept-Encoding: gzip
Content-Type: application/json
Cookie: sessionid=72g7136808dfqwrudc4ym6a471mxoh
X-Forwarded-For: xx.xx.xx.xx
X-Forwarded-Host: backend.ngrok-free.app
X-Forwarded-Proto: https

e
{"foo": "bar"}
0

I’m using background-runner version 1.1.0.

I’ve attempted to resolve this issue by manually adding the Content-Length header, but it did not work.

How can I ensure that the POST request is sent without chunked encoding and with the full content-length?

ref: #60 (comment)

PratikBodawala added a commit to PratikBodawala/capacitor-background-runner that referenced this issue Aug 26, 2024
@theproducer theproducer self-assigned this Aug 27, 2024
@theproducer theproducer added the bug Something isn't working label Aug 27, 2024
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