Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: ios/net/http_protocol_logging.mm

Issue 994823004: [iOS] Upstream //ios/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/net/http_protocol_logging.h"
6
7 #include <Foundation/Foundation.h>
8
9 #include "base/logging.h"
10 #include "base/strings/sys_string_conversions.h"
11 #import "ios/net/url_scheme_util.h"
12
13 namespace {
14 const unsigned int kMaxUrlLength = 100;
15 }
16
17 namespace net {
18
19 void LogNSURLRequest(NSURLRequest* request) {
20 DVLOG_IF(2, UrlHasDataScheme([request URL]) &&
21 [[[request URL] absoluteString] length] > kMaxUrlLength)
22 << "Request (data scheme) "
23 << base::SysNSStringToUTF8(
24 [[[request URL] absoluteString] substringToIndex:kMaxUrlLength])
25 << " ...";
26
27 DVLOG_IF(2, ![[[request URL] scheme] isEqualToString:@"data"] ||
28 [[[request URL] absoluteString] length] <= kMaxUrlLength)
29 << "Request "
30 << base::SysNSStringToUTF8([[request URL] description]);
31
32 DVLOG_IF(2, ![[request HTTPMethod] isEqualToString:@"GET"])
33 << base::SysNSStringToUTF8([request HTTPMethod]);
34
35 DVLOG_IF(2, [request allHTTPHeaderFields])
36 << base::SysNSStringToUTF8([[request allHTTPHeaderFields] description]);
37
38 DVLOG_IF(2, [request networkServiceType])
39 << "Service type: " << [request networkServiceType];
40
41 DVLOG_IF(2, ![request HTTPShouldHandleCookies]) << "No cookies";
42
43 DVLOG_IF(2, [request HTTPShouldUsePipelining]) << "Pipelining allowed";
44 }
45
46 void LogNSURLResponse(NSURLResponse* response) {
47 DVLOG_IF(2, UrlHasDataScheme([response URL]) &&
48 [[[response URL] absoluteString] length] > kMaxUrlLength)
49 << "Response (data scheme) "
50 << base::SysNSStringToUTF8(
51 [[[response URL] absoluteString] substringToIndex:kMaxUrlLength]);
52
53 DVLOG_IF(2, !UrlHasDataScheme([response URL]) ||
54 [[[response URL] absoluteString] length] <= kMaxUrlLength)
55 << "Response "
56 << base::SysNSStringToUTF8([[response URL] description]);
57
58 DVLOG_IF(2, [response isKindOfClass:[NSHTTPURLResponse class]] &&
59 [(NSHTTPURLResponse*)response allHeaderFields])
60 << base::SysNSStringToUTF8(
61 [[(NSHTTPURLResponse*)response allHeaderFields] description]);
62
63 DVLOG_IF(2, [response expectedContentLength])
64 << "Length: " << [response expectedContentLength];
65
66 DVLOG_IF(2, [response MIMEType])
67 << "MIMEType: " << base::SysNSStringToUTF8([response MIMEType]);
68
69 DVLOG_IF(2, [response isKindOfClass:[NSHTTPURLResponse class]])
70 << "Response code: " << [(NSHTTPURLResponse*)response statusCode];
71
72 DVLOG_IF(2, [response textEncodingName])
73 << "Text encoding: "
74 << base::SysNSStringToUTF8([response textEncodingName]);
75 }
76
77 } // namespace http_protocol_logging
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698