使用netcat询问HTTP GET请求

编程入门 行业动态 更新时间:2024-10-10 07:25:00
本文介绍了使用netcat询问HTTP GET请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 因此,我必须从 http:// www。 rssweather/dir/Asia/India 。

假设我想要检索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.1

I 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请求

本文发布于:2023-11-25 10:22:57,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:netcat   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!