Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-02-2011, 04:07 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default No http headers

Hey guys,

I am trying to find the http headers but I don't think my method is working.
I am using
Code:
- (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType {
NSMutableURLRequest *req = (NSMutableURLRequest *)request;
NSLog(@"http headers = %@", [req allHTTPHeaderFields]);
}
But the NSLog is printing out
Code:
http headers = {
Does anyone know why?

Thanks
Clinton
Shades of Chaos is offline   Reply With Quote
Old 08-02-2011, 05:27 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by Shades of Chaos View Post
Hey guys,

I am trying to find the http headers but I don't think my method is working.
I am using
Code:
- (BOOL)webView:(UIWebView *)webView2 shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType {
NSMutableURLRequest *req = (NSMutableURLRequest *)request;
NSLog(@"http headers = %@", [req allHTTPHeaderFields]);
}
But the NSLog is printing out
Code:
http headers = {
Does anyone know why?

Thanks
Clinton
Have you checked that req isn't nil?

Just out of curiosity... why are you casting to an NSMutableURLRequest?
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions

Last edited by MattW; 08-02-2011 at 06:07 PM. Reason: (Not paying attention to original post!!! My bad!)
MattW is offline   Reply With Quote
Old 08-02-2011, 05:37 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

Ah ok thank you. I am also trying to get the user-agent by using
Code:
NSLog(@"user agent = %@", [request valueForHTTPHeaderField: @"User-Agent"]);
And that is returning (null). I checked the docs and that method returns an NSString. Is user agent spelled in a different way or something?
Shades of Chaos is offline   Reply With Quote
Old 08-02-2011, 05:47 PM   #4 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

Also I was able to use this code
Code:
NSLog(@"%@", [httpResponse allHeaderFields]);
Where httpResponse was a NSHTTPURLResponse. This worked and printed out all the header fields. But now I am trying to use a NSUrlRequest
Shades of Chaos is offline   Reply With Quote
Old 08-02-2011, 06:04 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by Shades of Chaos View Post
Also I was able to use this code
Code:
NSLog(@"%@", [httpResponse allHeaderFields]);
Where httpResponse was a NSHTTPURLResponse. This worked and printed out all the header fields. But now I am trying to use a NSUrlRequest
Humble apologies... my brain was in C, rather than Objective-C, mode!!

Have you double-checked that req isn't coming back as nil?
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 08-02-2011, 06:15 PM   #6 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

No they are not. I turned both req and request into a string like
Code:
NSString *requestString = [[request URL] absoluteString];
NSString *requestString2 = [[req URL] absoluteString];
And neither of them print out nil
Shades of Chaos is offline   Reply With Quote
Old 08-02-2011, 06:38 PM   #7 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by Shades of Chaos View Post
No they are not. I turned both req and request into a string like
Code:
NSString *requestString = [[request URL] absoluteString];
NSString *requestString2 = [[req URL] absoluteString];
And neither of them print out nil
If I were you, I'd do a little NSLog walk of your dictionary, and see what's in it. Sounds like it might be empty?
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 08-02-2011, 06:48 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

I also think it is empty but I dont know why or how to fix it. When I use
Code:
NSLog(@"http headers = %@", [request allHTTPHeaderFields]);
	NSLog(@"http headers = %@", [req allHTTPHeaderFields]);
They both come out as
Code:
http headers = {
Shades of Chaos is offline   Reply With Quote
Reply

Bookmarks

Tags
headers, http, nsmutableurlrequest, webview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 392
15 members and 377 guests
7twenty7, blasterbr, buggen, chiataytuday, dedeys78, dre, fiftysixty, HemiMG, jimmyon122, jonathandeknudt, LEARN2MAKE, nyoe, pungs, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,902
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:03 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0