lazybios

curl调试http服务

开发微信公众平台时,因为公众号与用户的交互都要经过,腾讯的微信服务器post请求,,流程如下图(图是直接从网上down的)

图片

使用curl可以方便的调试公众账号服务端程序,省去了写form表单,直接在命令行下就能轻松搞定,下面记录的是curl的一些基本用法

###下载文件 curl -o [filename] url

###自动跳转 curl -L url
会根据跳转指示,跳到最终页面,不会停留到中间页面

###查看http请求详细信息

###提交信息到服务器 ####GET方式


<form method="GET" action="junk.cgi">   
 <input type=text name="birthyear">   
 <input type=submit name=press value="OK">   
 </form>   

####POST方式


<form method="POST" action="junk.cgi">   
 <input type=text name="birthyear">   
 <input type=submit name=press value="OK">   
 </form>   

###文件上传


<form method="POST" enctype='multipart/form-data' action="upload.cgi">

 <input type=file name=upload>
 <input type=submit name=press value="OK">
</form>

###参考 http://www.ruanyifeng.com/blog/2011/09/curl.html
http://curl.haxx.se/docs/httpscripting.html#The_HTTP_Protocol

微信关注「日拱一卒」公众号