简体   繁体   English

我如何使用带有请求或任何内容的node.js通过HTTP代理通过https获取数据

[英]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. 我有polipo实例在端口8123上的liunx服务器上运行,我需要通过此代理服务器在节点内部使用https进行获取和发布请求。 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 btw proxychains不足以完成此任务,因为它似乎将请求放入队列中,而不是一次打开多个连接,而我可以使用socks来完成任务,但是tsocks似乎根本不起作用

some other posts suggested that a get over http would work 其他一些帖子则建议您可以克服http

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. 注意,我们将完整的目标URL传递到path和Host标头中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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