LoginSignup
13
14

More than 5 years have passed since last update.

NSURLConnectionデフォルトのHTTPヘッダ

Posted at
- (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
13
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
14