Could you use asyncsocket? Its a Cocoa class built using CFNetworking and sockets and makes working with NSURL type stuff very very easy.

        asyncSocket = [[AsyncSocket alloc] initWithDelegate:self];
        [asyncSocket connectToHost:[url host] onPort:80 error:nil];

CFHTTPMessageRef httpRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, (CFStringRef)@"POST", (CFURLRef)url, kCFHTTPVersion1_1); CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("User-Agent"), (CFStringRef)@"MyUserAgent"); CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Content-Type"), (CFStringRef)headerfield); CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Content- Length"), (CFStringRef)[NSString stringWithFormat:@"%d", [data length] + fileSize + [finalData length]]); CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Accept"), (CFStringRef)@"text/plain, text/html, text/*"); CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Connection"), (CFStringRef)@"close"); CFHTTPMessageSetHeaderFieldValue(httpRequest, CFSTR("Host"), (CFStringRef)[url host]);
        
NSData *serialData = [(NSData *)CFHTTPMessageCopySerializedMessage(httpRequest) autorelease];
        CFRelease(httpRequest);

        //send the headers
        [asyncSocket writeData:serialData withTimeout:-1 tag:1];

Just an example.

On Jan 25, 2009, at 1:21 PM, John Michael Zorko wrote:


Hello, all ...

I guess this is more of a Core Foundation question, but it still seemed more apropos to this list than Carbon-dev. Please let me know if i'm wrong :-)

I'm trying to handle URLs in this format:

http://<user>:<password>@this.url.com/content

... with the <user> and <password> filled in of course. I found that NSURLConnection handled these for me, but for reasons beyond the scope of this question, NSURLConnection isn't a good choice for what i'm trying to do, so i'm using CFNetwork stuff. I've a question, though:

1. How do I get the HTTP return code? I use CFHTTPMessageCreateRequest() to create the GET request, and CFReadStreamCreateForHTTPRequest() to create a CFReadStream for said request. How do I get the response of the request?

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com



_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net

This email sent to [email protected]

Alex Kac - President and Founder
Web Information Solutions, Inc.




_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to