Illep
Illep

Reputation: 16841

ASIHTTPRequest adding headers to the request

I am using ASIHTTPRequest, and i have to make use of the POST method to send some values to the server. So, for this i have to set headers and its corresponding values.

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request addRequestHeader:@"Referer" value:@"http://allseeing-i.com/"];

The following are headers that is needed to be included in my application, and how could i include the once with Semi-Colons ("Content-Type" = "text/html"; , "Keep-Alive" = "timeout=15, max=100"; etc)

    "Content-Type" = "text/html";

    Date = "Wed, 21 Jun 2011 09:09:57 GMT";

    "Keep-Alive" = "timeout=15, max=100";

    Server = Apache;

    "Transfer-Encoding" = Identity;

Upvotes: 1

Views: 3211

Answers (2)

JosephH
JosephH

Reputation: 37495

Just use addRequestHeader in the same way as you're setting Referer. You don't need to include those semicolons - I think the ; are only there as an artifact of the method used to capture the headers. You do not use ; like that in HTTP.

eg:

[request addRequestHeader:@"Keep-Alive" value:@"timeout=15, max=100"];

Upvotes: 5

Aymarick
Aymarick

Reputation: 533

You just have to add [request setRequestMethod:@"POST"];

Upvotes: 1

Related Questions