NSURLRequest check
NSURLRequest check
- Subject: NSURLRequest check
- From: René v Amerongen <email@hidden>
- Date: Thu, 28 Jun 2007 17:36:36 +0200
Hello
Here goes definitely something wrong. I see nothing in apache's log
about the headers and the url, only that it give a page back.
I want to check if the POST URL with header and parameters are
correctly builded.
How can I do this in cocoa self, I mean when my code do create the
URL request and then I want to check if it was correct during sending?
This is the code I am using
NSURL* url = [NSURL URLWithString:@"http://10.0.0.44"];
NSMutableURLRequest* postURLRequest = [[NSMutableURLRequest alloc]
initWithURL:url];
[postURLRequest setHTTPMethod:@"POST"];
// setup de body
NSMutableData *postBody = [NSMutableData data];
[postBody appendData: [@"push?"
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData: [[@"DESTINATION="
stringByAppendingString:@"201tfhgd"]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData: [[@"&PORT=" stringByAppendingString:@"2014"]
dataUsingEncoding:NSUTF8StringEncoding]];
[postBody appendData: [[@"&REQUESTURI=" stringByAppendingString:@"/"]
dataUsingEncoding:NSUTF8StringEncoding]];
[postURLRequest setHTTPBody:postBody];
// setup the headers
[postURLRequest setValue:@"HTTP://www.test.net"
forHTTPHeaderField:@"content-location"];
[postURLRequest setValue:@"REFLEX" forHTTPHeaderField:@"Push-Title"];
[postURLRequest setValue:@"Browser-Channel" forHTTPHeaderField:@"Push-
Type"];
.....
//Start the connection with the post
dataConnection=[[NSURLConnection alloc]
initWithRequest:postURLRequest delegate:self];
A second question,
Am I missing some basic headers. What kind of headers do I always
need? Do I need to add the size of the postBody to the content-length
header or...
Thanks in advance
Rene
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden