Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
15
Help us understand the problem. What is going on with this article?
@laiso

NSURLConnectionデフォルトのHTTPヘッダ

More than 5 years have passed since last update.
- (void)send
{
  NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://ifconfig.me"]];
  NSLog(@"Accept-Encoding: %@", [req valueForHTTPHeaderField:@"Accept-Encoding"]);
  NSURLConnection *connection = [NSURLConnection connectionWithRequest:req delegate:self];
  [connection start];
}

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response
{
  NSLog(@"Accept-Encoding: %@", [request valueForHTTPHeaderField:@"Accept-Encoding"]);
  return request;
}

がこうなる。

2014-08-06 16:45:33.576 URLCache[299:60b] Accept-Encoding: (null)
2014-08-06 16:45:33.648 URLCache[299:60b] Accept-Encoding: gzip, deflate

po [request allHTTPHeaderFields]

po [request allHTTPHeaderFields]
{
    Accept = "*/*";
    "Accept-Encoding" = "gzip, deflate";
    "Accept-Language" = "ja-jp";
}

送られてるHTTPヘッダ。URLCacheはアプリ名。

Host                    ifconfig.me
Accept-Encoding         gzip, deflate
Accept                  */*
Accept-Language         ja-jp
Connection              keep-alive
User-Agent              URLCache/1.0 CFNetwork/672.0.8 Darwin/14.0.0
15
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
laiso
Software Engineer, Mobile Developer, Cloud Architect

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
15
Help us understand the problem. What is going on with this article?