Peter Lapisu
Peter Lapisu

Reputation: 20975

Cocoa ASIHTTP - HTTP/1.1 405 Method Not Allowed

i am using ASIHTTP (http://allseeing-i.com/ASIHTTPRequest/) to handle communication

standard web communication is ok, but when i want to download files, aim getting

HTTP/1.1 405 Method Not Allowed 

on different servers

this is my ASIFormDataRequest

ASIFormDataRequest * request = [ASIFormDataRequest requestWithURL:url];

[request setDownloadDestinationPath:destinationPath];

[request addRequestHeader:@"Connection"     value:@"Keep-Alive"];
[request addRequestHeader:@"Keep-Alive"     value:@"timeout=1000, max=20"];
[request addRequestHeader:@"Accept-Language"    value:@"en"];
[request addRequestHeader:@"Accept-Charset" value:@"utf-8"];
[request setAllowCompressedResponse:YES];
[request setShouldContinueWhenAppEntersBackground:YES];
[request setNumberOfTimesToRetryOnTimeout:3];

[request setPostValuesWithDictionary:postDictionary];

but in the didFinish aim getting a ASIHTTPRequest with response message 405

Upvotes: 0

Views: 773

Answers (2)

Joachim Isaksson
Joachim Isaksson

Reputation: 180917

Sounds like you're doing a POST instead of a GET to download the file when you're using ASIFormDataRequest (which afaik POSTS to a form).

You should normally fetch files using GET, which means you should probably use ASIHTTPRequest instead.

Upvotes: 1

Peter Lapisu
Peter Lapisu

Reputation: 20975

the solution is to use

ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL:url];

instead of

ASIFormDataRequest * request = [ASIFormDataRequest requestWithURL:url];

Upvotes: 0

Related Questions