PUT /test.txt HTTP/1.1
Accept: */*
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Win32)
Host: test.com:8080
hello world
要注意如下几个点:
① PUT方法是HTTP 1.1协议中才出现的。
② HTTP协议对空格敏感,每行数据的结尾不能出现空格
③ HTTP头部和数据中间要空一行,即HTTP头部是以\r\n\r\n结尾的。
④ 端口号直接跟在HOST后面 三、第一次PUT
好了,现在可以PUT了。用Linux下的nc命令来进行连接。
nc -v www.baidu.com 80
root@bb:/etc# nc -v 192.168.163.1 8080
nc: 192.168.163.1 (192.168.163.1) 8080 [http-alt] open
/*在得到如上输出之后,再将PUT包的内容贴到命令行中,回车*/
PUT /test.txt HTTP/1.1
Content-Length: 11
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Win32)
Host: 192.168.163.1:8080
hello world
/*发送的PUT包到此为止,以下为收到的数据包*/
HTTP/1.1 500 Internal Server Error
Date: Wed, 29 Apr 2015 09:15:18 GMT
Server: Apache/2.2.21 (Win64) PHP/5.3.10 DAV/2
Content-Length: 535
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p>
<p>Please contact the server administrator, admin@localhost and inform them of the time the error occurred,and anything you might have done that may have caused the error.</p>
<p>More information about this error may be available in the server error log.</p>
</body></html>
好像不对啊,500是服务器内部错误啊。好吧好吧,我们去看看主机的Apache日志。 四、再次配环境
主机用的是WAMP,日志在/wamp/logs/apache_error.log。找到对应的那一条:
通过浏览器搜索,又找到一篇日志。Linux(CentOS) 服务端搭建与配置,原来用HTTP - PUT还要添加一个什么锁。