加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

是否可以使用Linux命令从HTTP服务器读取前N个字节?

发布时间:2020-12-13 17:59:03 所属栏目:Linux 来源:网络整理
导读:这是问题. 给定url http://www.example.com,我们可以从页面中读取前N个字节吗? 使用wget,我们可以下载整个页面. 使用curl,有-r,0-499指定前500个字节.似乎解决了这个问题. You should also be aware that many HTTP/1.1 servers do not have this feature e
这是问题.

给定url http://www.example.com,我们可以从页面中读取前N个字节吗?

>使用wget,我们可以下载整个页面.
>使用curl,有-r,0-499指定前500个字节.似乎解决了这个问题.

You should also be aware that many HTTP/1.1 servers do not have this feature enabled,so that when you attempt to get a range,you’ll instead get the whole document.

>在python中使用urlib.类似的问题here,但根据康斯坦丁的评论,这是真的吗?

Last time I tried this technique it failed because it was actually impossible to read from the HTTP server only specified amount of data,i.e. you implicitly read all HTTP response and only then read first N bytes out of it. So at the end you ended up downloading the whole 1Gb malicious response.

那么问题是我们如何从HTTP服务器上读取第一个N个字节呢?

问候与谢谢

解决方法

curl <url> | head -c 499

要么

curl <url> | dd count=499

应该做

还有一个比较简单的utils可能是borader的可用性

netcat host 80 <<"HERE" | dd count=499 of=output.fragment
GET /urlpath/query?string=more&bloddy=stuff

HERE

要么

GET /urlpath/query?string=more&bloddy=stuff

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读