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

Unable to send empty post request #422

Open
iamoskvin opened this issue Dec 18, 2024 · 2 comments
Open

Unable to send empty post request #422

iamoskvin opened this issue Dec 18, 2024 · 2 comments

Comments

@iamoskvin
Copy link

iamoskvin commented Dec 18, 2024

I need to send a Post request without body.
Also, need to not include content-type header.
I can't do that because I am getting "Operation was aborted by an application callback" error when I am trying to not use POSTFIELDS. 
If I use POSTFIELDS as an empty string, then the content-type is set up by default, and I can't prevent it.
I tried both curly and Curl. Any ideas how I could achieve this with node-libcurl?
It works OK with curl itself: I was able to send a request without body and without any content-type.

This is an example with Curl

import { Curl, curly } from "node-libcurl";

const curl = new Curl();

curl.setOpt(Curl.option.VERBOSE, true);
curl.setOpt(Curl.option.USERAGENT, "myuseragent");
curl.setOpt(Curl.option.DEFAULT_PROTOCOL, "https");
curl.setOpt(Curl.option.PATH_AS_IS, true);
curl.setOpt(Curl.option.URL, "yahoo.com");
curl.setOpt(Curl.option.FOLLOWLOCATION, true);
curl.setOpt(Curl.option.POSTREDIR, 0);
curl.setOpt(Curl.option.MAXREDIRS, 10);

curl.setOpt(Curl.option.POST, 1);
curl.on("end", function (statusCode, body, headers) {
  console.log(statusCode);

  this.close();
});

curl.on("error", function (error) {
  console.log(error);

  this.close();
});

curl.perform();

@JCMais
Copy link
Owner

JCMais commented Dec 26, 2024

when using the CLI, what is the command you are using?

@iamoskvin
Copy link
Author

when using the CLI, what is the command you are using?

curl 'https://gateway-run.bls.dev/api/v1/nodes/someid/start-session'
-X 'POST'
-H 'accept: /'
-H 'accept-language: en-US,en;q=0.9,ru;q=0.8,ka;q=0.7'
-H 'authorization: Bearer some-token'
-H 'content-length: 0'
-H 'origin: chrome-extension://pljbjcehnhcnofmkdbjolghdcjnmekia'
-H 'priority: u=1, i'
-H 'sec-fetch-dest: empty'
-H 'sec-fetch-mode: cors'
-H 'sec-fetch-site: cross-site'
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
-H 'x-extension-version: 0.1.7'

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