本文整理了Java中io.restassured.http.Header.getName()
方法的一些代码示例,展示了Header.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header.getName()
方法的具体详情如下:
包路径:io.restassured.http.Header
类名称:Header
方法名:getName
暂无
代码示例来源:origin: rest-assured/rest-assured
public boolean hasSameNameAs(Header header) {
AssertParameter.notNull(header, Header.class);
return this.name.equalsIgnoreCase(header.getName());
}
代码示例来源:origin: rest-assured/rest-assured
private static String toString(Headers headers) {
if (!headers.exist()) {
return "";
}
final StringBuilder builder = new StringBuilder();
for (Header header : headers) {
builder.append(header.getName())
.append(HEADER_NAME_AND_VALUE_SEPARATOR)
.append(header.getValue())
.append(SystemUtils.LINE_SEPARATOR);
}
builder.delete(builder.length() - SystemUtils.LINE_SEPARATOR.length(), builder.length());
return builder.toString();
}
代码示例来源:origin: rest-assured/rest-assured
private static List<Header> removeMergedHeadersIfNeeded(List<Header> headerList, HeaderConfig headerConfig) {
List<Header> filteredList = new ArrayList<Header>();
for (Header header : headerList) {
String headerName = header.getName();
if (headerConfig.shouldOverwriteHeaderWithName(headerName)) {
int index = -1;
for (int i = 0; i < filteredList.size(); i++) {
Header filteredHeader = filteredList.get(i);
if (filteredHeader.hasSameNameAs(header)) {
index = i;
break;
}
}
if (index != -1) {
filteredList.remove(index);
}
}
filteredList.add(header);
}
return filteredList;
}
代码示例来源:origin: rest-assured/rest-assured
private void addRequestElements(HttpMethod method, String requestContentType, WebTestClient.RequestBodySpec requestBodySpec) {
verifyNoBodyAndMultipartTogether();
if (isNotBlank(requestContentType)) {
requestBodySpec.contentType(parseMediaType(requestContentType));
}
applyRequestBody(requestBodySpec);
applyMultipartBody(method, requestBodySpec);
applyAttributes(requestBodySpec);
headers.forEach(header -> requestBodySpec.header(header.getName(), header.getValue()));
cookies.asList().forEach(cookie -> requestBodySpec.cookie(cookie.getName(), cookie.getValue()));
}
代码示例来源:origin: rest-assured/rest-assured
request.header(header.getName(), header.getValue());
代码示例来源:origin: spring-projects/spring-restdocs
private boolean isAllMediaTypesAcceptHeader(Header header) {
return HttpHeaders.ACCEPT.equals(header.getName())
&& "*/*".equals(header.getValue());
}
代码示例来源:origin: spring-projects/spring-restdocs
private HttpHeaders extractHeaders(Response response) {
HttpHeaders httpHeaders = new HttpHeaders();
for (Header header : response.getHeaders()) {
httpHeaders.add(header.getName(), header.getValue());
}
return httpHeaders;
}
代码示例来源:origin: spring-projects/spring-restdocs
private HttpHeaders extractHeaders(FilterableRequestSpecification requestSpec) {
HttpHeaders httpHeaders = new HttpHeaders();
for (Header header : requestSpec.getHeaders()) {
if (!isAllMediaTypesAcceptHeader(header)) {
httpHeaders.add(header.getName(), header.getValue());
}
}
return httpHeaders;
}
代码示例来源:origin: com.adobe.ride/ride-core
/**
* Parses the headers returned in the call and formats them for reporting.
*
* @param headers construction method for getting a serialized list of the the headers used in the
* call
* @return String
*/
private String getHeaderString(Headers headers) {
String returnString = "";
boolean first = true;
for (Header h : headers) {
if (first) {
returnString += " " + h.getName() + ": " + h.getValue() + System.lineSeparator();
first = false;
} else {
returnString += " " + h.getName() + ": " + h.getValue() + System.lineSeparator();
}
}
return returnString;
}
代码示例来源:origin: epam/JDI
public void addHeader(Header header) {
addHeader(header.getName(), header.getValue());
}
public void addHeaders(com.epam.http.annotations.Header... headers) {
代码示例来源:origin: io.rest-assured/spring-commons
private static List<Header> removeMergedHeadersIfNeeded(List<Header> headerList, HeaderConfig headerConfig) {
List<Header> filteredList = new ArrayList<Header>();
for (Header header : headerList) {
String headerName = header.getName();
if (headerConfig.shouldOverwriteHeaderWithName(headerName)) {
int index = -1;
for (int i = 0; i < filteredList.size(); i++) {
Header filteredHeader = filteredList.get(i);
if (filteredHeader.hasSameNameAs(header)) {
index = i;
break;
}
}
if (index != -1) {
filteredList.remove(index);
}
}
filteredList.add(header);
}
return filteredList;
}
代码示例来源:origin: guru.nidi.raml/raml-tester
Values headersToValues(Headers headers) {
final Values headerValues = new Values();
for (final Header header : headers) {
headerValues.addValue(header.getName(), header.getValue());
}
return headerValues;
}
代码示例来源:origin: nidi3/raml-tester
protected Values headersToValues(Headers headers) {
final Values headerValues = new Values();
for (final Header header : headers) {
headerValues.addValue(header.getName(), header.getValue());
}
return headerValues;
}
代码示例来源:origin: ctco/cukes
public WebAddHeader map(Header header) {
WebAddHeader result = new WebAddHeader();
result.setName(header.getName());
result.setValue(header.getValue());
return result;
}
}
代码示例来源:origin: lv.ctco.cukesrest/cukes-rest-loadrunner
public WebAddHeader map(Header header) {
WebAddHeader result = new WebAddHeader();
result.setName(header.getName());
result.setValue(header.getValue());
return result;
}
}
代码示例来源:origin: lv.ctco.cukes/cukes-http
private void cacheHeaders(Response response) {
clearOldHeaders();
Headers headers = response.getHeaders();
for (Header header : headers) {
String headerName = CukesOptions.HEADER_PREFIX + header.getName();
world.put(headerName, header.getValue());
}
}
代码示例来源:origin: ctco/cukes
private void cacheHeaders(Response response) {
clearOldHeaders();
Headers headers = response.getHeaders();
for (Header header : headers) {
String headerName = CukesOptions.HEADER_PREFIX + header.getName();
world.put(headerName, header.getValue());
}
}
代码示例来源:origin: com.atlassian.oai/swagger-request-validator-restassured
/**
* Builds a {@link Response} for the OpenAPI validator out of the
* original {@link io.restassured.response.Response}.
*
* @param originalResponse the original {@link io.restassured.response.Response}
*/
@Nonnull
public static Response of(@Nonnull final io.restassured.response.Response originalResponse) {
requireNonNull(originalResponse, "An original response is required");
final SimpleResponse.Builder builder = new SimpleResponse.Builder(originalResponse.getStatusCode())
.withBody(originalResponse.getBody().asString());
if (originalResponse.getHeaders() != null) {
originalResponse.getHeaders().forEach(header -> builder.withHeader(header.getName(), header.getValue()));
}
return builder.build();
}
}
代码示例来源:origin: com.atlassian.oai/swagger-request-validator-restassured
.withBody(originalRequest.getBody());
if (originalRequest.getHeaders() != null) {
originalRequest.getHeaders().forEach(header -> builder.withHeader(header.getName(), header.getValue()));
内容来源于网络,如有侵权,请联系作者删除!