发送http删除请求
我需要如何发送 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];
}
但我得到了 404 状态。
有谁知道我错过了什么?
PS:我使用的是xcode 3.2.3,模拟器4.0
I need to how I can send an http delete request, I've implemented the code below
- (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.
Does anyone know what I'm missing??
P.S: I'm using xcode 3.2.3, simulator 4.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您的删除请求似乎已正确发出,但服务器选择以 404 - 文档未找到错误进行响应。
您也可以控制服务器应用程序吗?您确定服务器在该 URL 上有响应删除请求的资源吗?
如果您对发出的删除请求感到怀疑 - 我将使用 HTTP 代理直接检查请求,然后您可以与其他客户端进行比较。我会使用 Wireshark (在 Mac 上)。如果另一个客户端在 PC 上,您可以使用 Fiddler,这非常好。
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.
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?
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. I would use Wireshark (on the Mac). If the other client is on a PC, you could use Fiddler, which is excellent.