晚上看了下的curl和这两个工具,进行了比较和。它们的区别,我看到的有如下几点:1.curl是libcurl这个库支持的,wget是一个纯粹的命令行命令。2.curl支持更多的协议。curl supports FTP, FTPS, ,
HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, POP3, IMAP,
SMTP and RTSP at the time of this writing. Wget supports HTTP, HTTPS and
FTP.3.curl
默认支持HTTP1.1(也支持1.0),而wget仅仅支持HTTP1.0规范。引用wget的man page中的一段话吧,Please be
aware that Wget needs to know the size of the POST data in advance. It's
not quite clear how to work around this limitation inherent in
HTTP/1.0. Although HTTP/1.1 introduces chunked transfer that doesn't
require knowing the request length in advance, a client can't use
chunked unless it knows it's talking to an HTTP/1.1 .
And it can't know that until it receives a response, which in turn
requires the request to have been completed -- a chicken-and-egg
problem.4.curl在指定要下载的链接时能够支持URL的序列或集合,而wget则不能这样;5.wget支持递归下载,而curl则没有这个功能。(这是wget的一个主要好处,wget也是有优势的,呵呵)参考资料:http://daniel.haxx.se/docs/curl-vs-wget.html看着它们的man page里面对HTTP支持的描述,我又了解到了一点HTTP1.0和HTTP1.1的区别,HTTP1.1中增加的持续性连接(Persist Connection)与块编码(Chunked Encoding)技术。块传输编码(Chunked Transfer Coding)块
编码(chunked encoding)改变消息主体使消息主体(message
body,译注:消息主体与实体主体是有区别的,后面章节将会介绍)成块发送。每一个块有它自己的大小(size)指示器,在所有的块之后会紧接着一个可
选的包含实体头域的尾部(trailer)。这允许发送端能动态生成内容,并能携带有用的信息,这些信息能让接收者判断消息是否接收完整。为啥突然想到看这个呢,其实起因是下面所说的。今天,看到环境更新脚本中,添加了一段脚本,里面用到了curl这个工具。这段程序如下:curl -u abc:123456 -o dirname base_url="" while read LINE do if [ -z "$LINE" ]; then continue fi echo $LINE |grep "dir name" if [ $? -eq 1 ]; then continue fi dir=`echo $LINE |sed -e 's/ svn_url=$base_url$dir/trunk svn co $svn_url $dir done < dirname |
这段代码是为了得到svn上的smile目录上的所有目录名称,并将其拼装成svn_url,然后checkout这些url。svn_url如下所示:aiscclient/下载得到的dirname这个文件内容如下: href CDATA #REQUIRED> href CDATA #REQUIRED> ]> href="">
|
更多关于curl和wget的介绍可以看man page用法示例,参考资料:
阅读(1434) | 评论(0) | 转发(0) |