• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting HTTP response headers and status code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting HTTP response headers and status code


  • Subject: Re: Getting HTTP response headers and status code
  • From: Dave Hersey <email@hidden>
  • Date: Sun, 08 Feb 2004 13:24:52 -0500

Marco,

Check that the response is an HTTPURLResponse, and then just cast it.
Something like:

- (void) download: (NSURLDownload *) download
didReceiveResponse: (NSURLResponse *) response
{
if (response && ([response class] == [NSHTTPURLResponse class]))
{
NSDictionary *allHeaderFields;
int statusCode;

allHeaderFields = [(NSHTTPURLResponse *) response allHeaderFields];

statusCode = [allHeaderFields statusCode];

NSLog(@"statusCode = %d [\"%@\"]",
statusCode,
[allHeaderFields localizedStringForStatusCode: statusCode]);
}
else
{
// Not an NSHTTPURLResponse. I'm not sure why you would get here,
// since you're doing the requesting...

}
}

- dave


On 2/8/04 11:08 AM, "Marco Michieli" <email@hidden> wrote:

> I need some help!
>
> I would like to get the HTTP response headers and status code to a URL
> load request.
>
> I know that there are specific methods in NSHTTPURLResponse to do that:
>
>  allHeaderFields
> + localizedStringForStatusCode:
>  statusCode
>
> But what I can't get is an instance of NSHTTPURLResponse: in fact when
> I create the connection (that is a NSURLConnection) the delegate method:
>
>  connection:didReceiveResponse:
>
> gives a response that is just a NSURLResponse and so I can't use such
> methods.
>
>
> Should be very easy, but I can't figure out how to get it work.
>
> Any suggestion?
>
> Thanks in advance
>
> Marco
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Getting HTTP response headers and status code (From: Marco Michieli <email@hidden>)

  • Prev by Date: Re: Document App or not?
  • Next by Date: Re: NSTableView Row header
  • Previous by thread: Getting HTTP response headers and status code
  • Next by thread: Characters with accents in NSString
  • Index(es):
    • Date
    • Thread