|
发表于 2013-3-1 15:03:37
|
显示全部楼层
你这叫自己实现HTTP协议而不是写HTTP头,
应当用TCP协议写而不是HTTP。
http头不是这样写,好好看一下教程吧写的很详细有示例
http://bbs.aardio.com/thread-6214-1-1.html
用TCP实现HTTP协议- import wsock.tcp.client;
- var tcp = wsock.tcp.client()
- tcp.connect("bbs.aardio.com",80)
- sendData =/***********
- GET / HTTP/1.1
- Host: bbs.aardio.com
- Connection: keep-alive
- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)
- Cache-Control: max-age=0
- Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain,image/png,*/*;
- Accept-Language: zh-CN,zh;
- Accept-Charset: GBK,utf-8;
- ***********/
- tcp.write( sendData + '\r\n\r\n' )
- import console
- for(str,size in tcp.eachRead() ){
- console.log( str );
- }
- tcp.close()
复制代码 自定义HTTP头- import zlib;
- import inet.whttp;
- var http = inet.whttp();
- var str = http.get("http://www.sohu.com"
- ,"Accept-Encoding:gzip, deflate" //自定义HTTP头
- )
- str = zlib.gzUncompress(str)
- import console;
- console.log( str)
复制代码 |
评分
-
查看全部评分
|