简体   繁体   English

发送http删除请求

[英]Send an http delete request

I need to how I can send an http delete request, I've implemented the code below 我需要如何发送http删除请求,我已经实现了下面的代码

- (void) deleteSyncRequestWithURL:(NSString *) url
{
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

    [request setURL:[NSURL URLWithString:url]];
    [request setHTTPMethod:@"DELETE"];  
    _connection = [[NSURLConnection connectionWithRequest:request delegate:self] retain];    
}

But I've got a 404 status. 但我有404状态。

Does anyone know what I'm missing?? 有谁知道我错过了什么?

PS: I'm using xcode 3.2.3, simulator 4.0 PS:我正在使用xcode 3.2.3,模拟器4.0

It looks as if your Delete request is being issued correctly, but the server is choosing to respond with a 404 - document not found error. 看起来好像是正确发出了删除请求,但是服务器选择回复404 - 找不到文档错误。

Do you have control over the server application too? 您是否也可以控制服务器应用程序? Are you sure the server has a resource at that URL that responds to a Delete request? 您确定服务器在该URL上有一个响应删除请求的资源吗?

If you are suspicious of the Delete request being made - I would use an HTTP proxy to examine the request directly, you can then compare to your other client. 如果您对正在进行的删除请求持怀疑态度 - 我会使用HTTP代理直接检查请求,然后您可以与其他客户端进行比较。 I would use Wireshark (on the Mac). 我会使用Wireshark (在Mac上)。 If the other client is on a PC, you could use Fiddler , which is excellent. 如果其他客户端在PC上,您可以使用Fiddler ,这非常好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM