简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM