• 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: HEAD request using NSURLConnection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HEAD request using NSURLConnection


  • Subject: Re: HEAD request using NSURLConnection
  • From: Patrick Machielse <email@hidden>
  • Date: Fri, 23 Jan 2004 13:42:35 +0100

op 23-01-2004 07:00 schreef Daniel Miao:

> I have been trying to get the content length of a URL using an HTTP
> HEAD request.
>
> Here is my code snippet:
>
> NSMutableURLRequest *request = [NSMutableURLRequest
> requestWithURL:aURL
> cachePolicy:NSURLRequestReloadIgnoringCacheData
> timeoutInterval:30.0];
>
> [request setHTTPMethod:@"HEAD"];
>
> NSURLResponse *response = [[NSURLResponse alloc] init];
> NSError *error = [[NSError alloc] init];
>
> [NSURLConnection sendSynchronousRequest:request
> returningResponse:&response error:&error];

Daniel,

I don't recognize the symptoms you describe, but since this is a synchronous
call it will wait until all data is in.

I also want to point out a memory leak in your code. In my experience
sendSynchronousRequest::: returns response and error as autoreleased
objects. You only have to pass 'adresses of pointers to NSURLResponse and
NSError'. So:

NSError *error;
NSURLResponse *response;
NSData *dataReply;
dataReply = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];

Should suffice. This isn't in the documentation but I _feel_ this is the way
to do it :-)

Groeten,

Patrick
--
Hieper Software

w: www.hieper.nl
e: email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: HEAD request using NSURLConnection
      • From: Daniel Miao <email@hidden>
  • Prev by Date: Re: FileWrapper Icon for non-document based app
  • Next by Date: Re: FileWrapper Icon for non-document based app
  • Previous by thread: Re: HEAD request using NSURLConnection
  • Next by thread: Re: HEAD request using NSURLConnection
  • Index(es):
    • Date
    • Thread