use of core.framework.impl.log.filter.FieldParam in project core-ng-project by neowu.
the class ResponseHandler method putCookies.
private void putCookies(ResponseImpl response, HttpServerExchange exchange) {
if (response.cookies != null) {
Map<String, Cookie> cookies = exchange.getResponseCookies();
response.cookies.forEach((spec, value) -> {
CookieImpl cookie = cookie(spec, value);
cookies.put(spec.name, cookie);
logger.debug("[response:cookie] name={}, value={}, domain={}, path={}, secure={}, httpOnly={}, maxAge={}", spec.name, new FieldParam(spec.name, cookie.getValue()), cookie.getDomain(), cookie.getPath(), cookie.isSecure(), cookie.isHttpOnly(), cookie.getMaxAge());
});
}
}
use of core.framework.impl.log.filter.FieldParam in project core-ng-project by neowu.
the class ResponseHandler method putHeaders.
private void putHeaders(ResponseImpl response, HttpServerExchange exchange) {
HeaderMap headers = exchange.getResponseHeaders();
response.headers.forEach((name, value) -> {
headers.put(name, value);
logger.debug("[response:header] {}={}", name, new FieldParam(name, value));
});
}
use of core.framework.impl.log.filter.FieldParam in project core-ng-project by neowu.
the class RequestParser method parseForm.
private void parseForm(RequestImpl request, HttpServerExchange exchange) {
FormData formData = exchange.getAttachment(FormDataParser.FORM_DATA);
if (formData == null)
return;
for (String name : formData) {
FormData.FormValue value = formData.getFirst(name);
if (value.isFile()) {
if (!Strings.isEmpty(value.getFileName())) {
// browser passes empty file name if not choose file in form
logger.debug("[request:file] {}={}, size={}", name, value.getFileName(), Files.size(value.getPath()));
request.files.put(name, new MultipartFile(value.getPath(), value.getFileName(), value.getHeaders().getFirst(Headers.CONTENT_TYPE)));
}
} else {
logger.debug("[request:form] {}={}", name, new FieldParam(name, value.getValue()));
request.formParams.put(name, value.getValue());
}
}
}
use of core.framework.impl.log.filter.FieldParam in project core-ng-project by neowu.
the class HTTPClientImpl method httpRequest.
HttpUriRequest httpRequest(HTTPRequest request) {
HTTPMethod method = request.method();
String uri = request.uri();
logger.debug("[request] method={}, uri={}", method, uri);
RequestBuilder builder = RequestBuilder.create(method.name());
try {
builder.setUri(uri);
} catch (IllegalArgumentException e) {
throw new HTTPClientException("uri is invalid, uri=" + uri, "INVALID_URL", e);
}
request.headers().forEach((name, value) -> {
logger.debug("[request:header] {}={}", name, new FieldParam(name, value));
builder.setHeader(name, value);
});
request.params().forEach((name, value) -> {
logger.debug("[request:param] {}={}", name, value);
builder.addParameter(name, value);
});
byte[] body = request.body();
if (body != null) {
ContentType contentType = request.contentType();
logRequestBody(request, contentType);
org.apache.http.entity.ContentType type = org.apache.http.entity.ContentType.create(contentType.mediaType(), contentType.charset().orElse(null));
builder.setEntity(new ByteArrayEntity(request.body(), type));
}
return builder.build();
}
Aggregations