• 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: Howto: send cookies/customize HTTP request headers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Howto: send cookies/customize HTTP request headers?


  • Subject: Re: Howto: send cookies/customize HTTP request headers?
  • From: Axel Behr <email@hidden>
  • Date: Sat, 17 Nov 2001 01:18:51 +0100

Anyway, looking into the headers and documentation for NSURL/NSURLHandle, i didn't see a way to insert anything into the HTTP header being generated.

O.k. Thanks to MTLibrarian I found what I was expecting to find in the release notes for foundation (btw. what I don't get is: if MTLibrarian is a clone of NeXT's Digital Librarian, why does Apple use Help Viewer for developer docs then...?!):

NSURL/NSURLHandle

Support for https has been added to NSURL/NSURLHandle; you can now download https URLs as you would http URLs. Also, it is now possible to configure the headers on the outgoing HTTP request via -writeProperty:forKey:. To do this, get an NSURLHandle from the relevant NSURL and prior to calling either -resourceData or -loadInBackground, message the handle with -writeProperty:forKey:; the key should be the HTTP header you wish to set and the property value should be an NSString containing the desired unquoted value for the header, for instance:

NSURL *url = [NSURL URLWithString:@"http://www.apple.com/";];
NSURLHandle *handle = [url URLHandleUsingCache:NO];
NSData *pageData;
[handle writeProperty:@"MyApp/1.0" forKey:@"User-Agent"];
pageData = [handle resourceData];

Now, this leads my to another problem:

The header parameter that is generated looks like this:

GET /pathonhost HTTP/1.0
Host: my.host.com:80
^^^
User-Agent: CFNetwork/0.9

To add the port address after the host name is quite uncommon (at least IE, which I checked, doesn't do this), and one of the servers I try to connect to chokes over this.

I can override the User-Agent (see source above), which works, but trying to override the Host property ends up being ignored. Any chances of removing the port number somehow else?

Is this behavioue RFC-compliant and are the browsers (i.e. IE) wrong about it, or can this be seen as some kind of bug or glitch an Apple's half?

Thanks for listening

Axel Behr


References: 
 >Howto: send cookies/customize HTTP request headers? (From: Axel Behr <email@hidden>)

  • Prev by Date: fetching help!!
  • Next by Date: Window load delegate function?
  • Previous by thread: Howto: send cookies/customize HTTP request headers?
  • Next by thread: Re: Howto: send cookies/customize HTTP request headers?
  • Index(es):
    • Date
    • Thread