(String configKey, Level logLevel, Request request)
| 66 | } |
| 67 | |
| 68 | protected void logRequest(String configKey, Level logLevel, Request request) { |
| 69 | String protocolVersion = resolveProtocolVersion(request.protocolVersion()); |
| 70 | log(configKey, "---> %s %s %s", request.httpMethod().name(), request.url(), protocolVersion); |
| 71 | if (logLevel.ordinal() >= Level.HEADERS.ordinal()) { |
| 72 | |
| 73 | for (String field : request.headers().keySet()) { |
| 74 | if (shouldLogRequestHeader(field)) { |
| 75 | for (String value : valuesOrEmpty(request.headers(), field)) { |
| 76 | log(configKey, "%s: %s", field, value); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | int bodyLength = 0; |
| 82 | if (request.body() != null) { |
| 83 | bodyLength = request.length(); |
| 84 | if (logLevel.ordinal() >= Level.FULL.ordinal()) { |
| 85 | String bodyText = |
| 86 | request.charset() != null ? new String(request.body(), request.charset()) : null; |
| 87 | log(configKey, ""); // CRLF |
| 88 | log(configKey, "%s", bodyText != null ? bodyText : "Binary data"); |
| 89 | } |
| 90 | } |
| 91 | log(configKey, "---> END HTTP (%s-byte body)", bodyLength); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | protected void logRetry(String configKey, Level logLevel) { |
| 96 | log(configKey, "---> RETRYING"); |
no test coverage detected