use of io.restassured.authentication.NoAuthScheme in project rest-assured by rest-assured.
the class MockMvcRequestSenderImpl method logRequestIfApplicable.
private void logRequestIfApplicable(HttpMethod method, String uri, String originalPath, Object[] unnamedPathParams) {
if (requestLoggingFilter == null) {
return;
}
final RequestSpecificationImpl reqSpec = new RequestSpecificationImpl("http://localhost", RestAssured.UNDEFINED_PORT, "", new NoAuthScheme(), Collections.<Filter>emptyList(), null, true, ConfigConverter.convertToRestAssuredConfig(config), logRepository, null);
reqSpec.setMethod(method.toString());
reqSpec.path(uri);
reqSpec.buildUnnamedPathParameterTuples(unnamedPathParams);
if (params != null) {
new ParamLogger(params) {
protected void logParam(String paramName, Object paramValue) {
reqSpec.param(paramName, paramValue);
}
}.logParams();
}
if (queryParams != null) {
new ParamLogger(queryParams) {
protected void logParam(String paramName, Object paramValue) {
reqSpec.queryParam(paramName, paramValue);
}
}.logParams();
}
if (formParams != null) {
new ParamLogger(formParams) {
protected void logParam(String paramName, Object paramValue) {
reqSpec.formParam(paramName, paramValue);
}
}.logParams();
}
if (headers != null) {
for (Header header : headers) {
reqSpec.header(header);
}
}
if (cookies != null) {
for (Cookie cookie : cookies) {
reqSpec.cookie(cookie);
}
}
if (requestBody != null) {
if (requestBody instanceof byte[]) {
reqSpec.body((byte[]) requestBody);
} else if (requestBody instanceof File) {
String contentType = findContentType();
String charset = null;
if (StringUtils.isNotBlank(contentType)) {
charset = CharsetExtractor.getCharsetFromContentType(contentType);
}
if (charset == null) {
charset = Charset.defaultCharset().toString();
}
String string = fileToString((File) requestBody, charset);
reqSpec.body(string);
} else {
reqSpec.body(requestBody);
}
}
if (multiParts != null) {
for (MockMvcMultiPart multiPart : multiParts) {
reqSpec.multiPart(new MultiPartSpecBuilder(multiPart.getContent()).controlName(multiPart.getControlName()).fileName(multiPart.getFileName()).mimeType(multiPart.getMimeType()).build());
}
}
String uriPath = PathSupport.getPath(uri);
String originalUriPath = PathSupport.getPath(originalPath);
requestLoggingFilter.filter(reqSpec, null, new FilterContextImpl(uri, originalUriPath, uriPath, uri, uri, new Object[0], method.toString(), null, Collections.<Filter>emptyList().iterator(), new HashMap<String, Object>()));
}
Aggregations