|
7 | 7 | import org.elasticsearch.rest.RestController; |
8 | 8 | import org.elasticsearch.common.inject.Inject; |
9 | 9 | import org.elasticsearch.common.Base64; |
10 | | - |
11 | 10 | import org.elasticsearch.rest.RestRequest; |
12 | 11 |
|
13 | 12 | import static org.elasticsearch.rest.RestStatus.*; |
|
16 | 15 | import java.util.Arrays; |
17 | 16 | import java.util.HashSet; |
18 | 17 | import java.util.Set; |
| 18 | + |
19 | 19 | import org.elasticsearch.common.logging.Loggers; |
| 20 | +import org.elasticsearch.rest.BytesRestResponse; |
20 | 21 | import org.elasticsearch.rest.RestRequest.Method; |
21 | | -import org.elasticsearch.rest.StringRestResponse; |
22 | 22 |
|
23 | 23 | // # possible http config |
24 | 24 | // http.basic.user: admin |
@@ -70,15 +70,15 @@ public void internalDispatchRequest(final HttpRequest request, final HttpChannel |
70 | 70 |
|
71 | 71 | // allow health check even without authorization |
72 | 72 | if (healthCheck(request)) { |
73 | | - channel.sendResponse(new StringRestResponse(OK, "{\"OK\":{}}")); |
| 73 | + channel.sendResponse(new BytesRestResponse(OK, "{\"OK\":{}}")); |
74 | 74 | } else if (allowOptionsForCORS(request) || authBasic(request) || isInIPWhitelist(request)) { |
75 | 75 | super.internalDispatchRequest(request, channel); |
76 | 76 | } else { |
77 | 77 | String addr = getAddress(request); |
78 | 78 | Loggers.getLogger(getClass()).error("UNAUTHORIZED type:{}, address:{}, path:{}, request:{}, content:{}, credentials:{}", |
79 | 79 | request.method(), addr, request.path(), request.params(), request.content().toUtf8(), getDecoded(request)); |
80 | 80 |
|
81 | | - StringRestResponse response = new StringRestResponse(UNAUTHORIZED, "Authentication Required"); |
| 81 | + BytesRestResponse response = new BytesRestResponse(UNAUTHORIZED, "Authentication Required"); |
82 | 82 | response.addHeader("WWW-Authenticate", "Basic realm=\"Restricted\""); |
83 | 83 | channel.sendResponse(response); |
84 | 84 | } |
|
0 commit comments