开发者

how do i use node.js with request or anything to get data over https through a http proxy

开发者 https://www.devze.com 2023-03-24 14:27 出处:网络
I have i instance of polipo running on a liunx server on port 8123 I need to make get and post requests with https inside of node through this proxy server.

I have i instance of polipo running on a liunx server on port 8123 I need to make get and post requests with https inside of node through this proxy server. how would i do this.

btw proxychains is inadequate for this task as it seems to put requests in queue instead of opening many connections at a time I could use socks for my task but tsocks seems to not work at all

some other posts suggested that a get over http would work

it does not


Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET https://www.google.com/accounts/OAuthGetRequestToken HTTP/1.1

HTTP/1.1 400 Couldn't parse URL
Connection: keep-alive
Date: Tue, 02 Aug 2011 23:50:34 GMT
开发者_运维问答Content-Type: text/html
Content-Length: 487
Expires: 0
Cache-Control: no-cache
Pragma: no-cache

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<title>Proxy error: 400 Couldn't parse URL.</title>
</head><body>
<h1>400 Couldn't parse URL</h1>
<p>The following error occurred while trying to access <strong>https://www.google.com/accounts/OAuthGetRequestToken</strong>:<br><br>
<strong>400 Couldn't parse URL</strong></p>
<hr>Generated Tue, 02 Aug 2011 19:50:34 EDT by Polipo on <em>ubuntu:8123</em>.
</body></html>

Connection closed by foreign host.

just how to i make this work


As you don't show any of your code, it is diffcult to determine you problem. However, try this:

var http = require("http");
var options = {
  host: "localhost",
  port: 8118,
  path: "http://check.torproject.org",
  method: 'POST',
  headers: {
    Host: "http://check.torproject.org",
  }
};
var req = https.request(options, function(res) {
  res.on('data', function (chunk) {
    console.log('BODY: ' + chunk);
  });
});

Note, we pass the full destination URL into path and the Host header.

0

精彩评论

暂无评论...
验证码 换一张
取 消