假设我想要检索Kanpur's。
如何使用Netcat发出HTTP GET请求?
我正在做这样的事情。
nc -v rss天气 80 GET www.rssweather/wx/in/kanpur/wx.php HTTP / 1.1我不知道我的方向是否正确。我无法找到任何有关如何使用netcat发出HTTP请求的好教程,所以我将它发布到这里。
当然,你可以挖掘搜索谷歌的标准,但实际上,如果你只想得到一个URL,那就不值得付出努力。
您还可以在监听模式下启动一个netcat:
nc -l 64738...然后用真正的浏览器向此端口发送浏览器请求。只需输入您的浏览器 http:// localhost:64738 并查看。
在您的实际情况中,问题是HTTP / 1.1不会自动关闭连接,但它会等待您想要检索的下一个URL。解决方案很简单:
使用HTTP / 1.0:
GET / this / url / you / want / to / get HTTP / 1.0 Host:www.rssweather <空行>或者使用连接:请求标题在这之后说你要关闭的服务器:
GET / this / url / you / want / to / get HTTP / 1.1 主持人:www.rssweather 连线:关闭<空行>扩展名: GET头只写入请求的路径部分。您希望获取数据的主机名属于 Host:标题,如您在示例中所见。这是因为多个网站可以在同一个网络服务器上运行,所以浏览器需要说他,他们要从哪个服务器加载页面。
So, I have to retrieve temperature from any one of the cities from www.rssweather/dir/Asia/India.
Let's assume I want to retrieve of Kanpur's.
How to make an HTTP GET request with Netcat?
I'm doing something like this.
nc -v rssweather 80 GET www.rssweather/wx/in/kanpur/wx.php HTTP/1.1I don't know exactly if I'm even in the right direction or not. I am not able to find any good tutorials on how to make an HTTP get request with netcat, so I'm posting it on here.
解决方案Of course you could dig in standards searched for google, but actually if you want to get only a single URL, it doesn't worth the effort.
You could also start a netcat in listening mode on a port:
nc -l 64738...and then do a browser request into this port with a real browser. Just type in your browser localhost:64738 and see.
In your actual case the problem is that HTTP/1.1 doesn't close the connection automatically, but it waits your next URL you want to retrieve. The solution is simple:
Use HTTP/1.0:
GET /this/url/you/want/to/get HTTP/1.0 Host: www.rssweather <empty line>or use a Connection: request header to say the server you want to close after that:
GET /this/url/you/want/to/get HTTP/1.1 Host: www.rssweather Connection: close <empty line>Extension: After the GET header write only the path part of the request. The hostname from which you want to get data belongs to a Host: header as you can see in my examples. This is because multiple websites can run on the same webserver, so the browsers need to say him, from which server they want to load the page.
更多推荐
使用netcat询问HTTP GET请求
发布评论