http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 7254|回复: 9

[咨询站长] method = PUT怎么办?

[复制链接]
发表于 2014-12-13 21:22:33 | 显示全部楼层 |阅读模式
1金钱
请问苏飞站长,method = PUT怎么办?HttpHelper累能处理吗?

QQ截图20141213212118.png


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
发表于 2014-12-13 21:59:40 | 显示全部楼层
怎么还有这种方法呀见鬼了吧
回复

使用道具 举报

 楼主| 发表于 2014-12-13 22:05:28 | 显示全部楼层
必须有啊,只是不太常见,我也是第一次碰到。在线等站长回答呢。
回复

使用道具 举报

发表于 2014-12-15 08:29:58 | 显示全部楼层
put就是向Web Server服务器扔资源,意思就是上传资源了,这里原文解释,不过实际操作起来可能会让诸位看官喝一壶,E文定义如下:

The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource, and that URI is capable of being defined as a new resource by the requesting user agent, the origin server can create the resource with that URI. If a new resource is created, the origin server MUST inform the user agent via the 201 (Created) response. If an existing resource is modified, either the 200 (OK) or 204 (No Content) response codes SHOULD be sent to indicate successful completion of the request. If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem. The recipient of the entity MUST NOT ignore any Content-* (e.g. Content-Range) headers that it does not understand or implement and MUST return a 501 (Not Implemented) response in such cases.

If the request passes through a cache and the Request-URI identifies one or more currently cached entities, those entries SHOULD be treated as stale. Responses to this method are not cacheable.

The fundamental difference between the POST and PUT requests is reflected in the different meaning of the Request-URI. The URI in a POST request identifies the resource that will handle the enclosed entity. That resource might be a data-accepting process, a gateway to some other protocol, or a separate entity that accepts annotations. In contrast, the URI in a PUT request identifies the entity enclosed with the request -- the user agent knows what URI is intended and the server MUST NOT attempt to apply the request to some other resource. If the server desires that the request be applied to a different URI,

it MUST send a 301 (Moved Permanently) response; the user agent MAY then make its own decision regarding whether or not to redirect the request.

A single resource MAY be identified by many different URIs. For example, an article might have a URI for identifying "the current version" which is separate from the URI identifying each particular version. In this case, a PUT request on a general URI might result in several other URIs being defined by the origin server.

HTTP/1.1 does not define how a PUT method affects the state of an origin server.

PUT requests MUST obey the message transmission requirements set out in section 8.2.

Unless otherwise specified for a particular entity-header, the entity-headers in the PUT request SHOULD be applied to the resource created or modified by the PUT.
回复

使用道具 举报

发表于 2014-12-15 08:33:32 | 显示全部楼层
要让Web Server支持Delete 和 Put请求方法,以Tomcat为例:
在Tomcat的web.xml 文件中配置 org.apache.catalina.servlets.DefaultServlet 的初始化参数
[xhtml] view plaincopy
<init-param>   
    <param-name>readonly</param-name>   
    <param-value>false</param-value>   
</init-param>  
readonly参数默认是true,即不允许delete和put操作,所以默认的通过XMLHttpRequest对象的put或者delete方法访问就会报告 http 403 forbidden 错误。所以要将readonly设置为false
接下来,从客户端通过 Ajax XMLHTTPRequest 发起 DELETE/PUT 请求:
[javascript] view plaincopy
function getXMLHTTPRequest(){  
    if (XMLHttpRequest)    {  
        return new XMLHttpRequest();  
    } else {  
        try{  
            return new ActiveXObject('Msxml2.XMLHTTP');  
        }catch(e){  
            return new ActiveXObject('Microsoft.XMLHTTP');  
        }  
    }  
}  
var req = getXMLHTTPRequest();  
req.open('DELETE','http://localhost/test.jsp',false);  
req.send(null);  
document.write(req.responseText);  
WebDAV也需要使用到这2种Http请求方法。
回复

使用道具 举报

 楼主| 发表于 2014-12-16 19:08:05 | 显示全部楼层
ching126 发表于 2014-12-15 08:29
put就是向Web Server服务器扔资源,意思就是上传资源了,这里原文解释,不过实际操作起来可能会让诸位看官 ...

我是在做NIKE网站模拟修改地址时,发现它是用PUT提交的数据,而我使用HttpHelper类发现result.StatusCode == System.Net.HttpStatusCode.BadRequest。一直没有找到,请高手帮我下哈!
回复

使用道具 举报

 楼主| 发表于 2014-12-16 19:08:16 | 显示全部楼层
ching126 发表于 2014-12-15 08:29
put就是向Web Server服务器扔资源,意思就是上传资源了,这里原文解释,不过实际操作起来可能会让诸位看官 ...

我是在做NIKE网站模拟修改地址时,发现它是用PUT提交的数据,而我使用HttpHelper类发现result.StatusCode == System.Net.HttpStatusCode.BadRequest。一直没有找到,请高手帮我下哈!
回复

使用道具 举报

 楼主| 发表于 2014-12-16 19:08:37 | 显示全部楼层
ching126 发表于 2014-12-15 08:29
put就是向Web Server服务器扔资源,意思就是上传资源了,这里原文解释,不过实际操作起来可能会让诸位看官 ...

我是在做NIKE网站模拟修改地址时,发现它是用PUT提交的数据,而我使用HttpHelper类发现result.StatusCode == System.Net.HttpStatusCode.BadRequest。一直没有找到,请高手帮我下哈!
回复

使用道具 举报

发表于 2014-12-16 19:51:23 | 显示全部楼层
无包无法测……
回复

使用道具 举报

发表于 2014-12-17 11:48:49 | 显示全部楼层
如果用put提交的数据说明此数据时上传资源,您要获取信息的时候必须有权限也可以,普通的get和post就是只读的意思,首先您要理解put的原理然后可以,或者您可以把您的想要获取的数据或想实现的东东描述的更清楚,可以帮你分析一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-11-24 12:52

© 2014-2021

快速回复 返回顶部 返回列表