本文整理了Java中org.mockserver.model.HttpResponse.replaceHeader()
方法的一些代码示例,展示了HttpResponse.replaceHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.replaceHeader()
方法的具体详情如下:
包路径:org.mockserver.model.HttpResponse
类名称:HttpResponse
方法名:replaceHeader
[英]Update header to return as a Header object, if a header with the same name already exists it will be modified
[中]更新标头以作为标头对象返回,如果已存在同名的标头,则将对其进行修改
代码示例来源:origin: jamesdbloom/mockserver
@Override
public void writeResponse(HttpRequest request, HttpResponseStatus responseStatus, String body, String contentType) {
HttpResponse response = response()
.withStatusCode(responseStatus.code())
.withBody(body);
if (body != null && !body.isEmpty()) {
response.replaceHeader(header(CONTENT_TYPE.toString(), contentType + "; charset=utf-8"));
}
writeResponse(request, response, true);
}
代码示例来源:origin: jamesdbloom/mockserver
@Override
public void writeResponse(HttpRequest request, HttpResponseStatus responseStatus, String body, String contentType) {
HttpResponse response = response()
.withStatusCode(responseStatus.code())
.withReasonPhrase(responseStatus.reasonPhrase())
.withBody(body);
if (body != null && !body.isEmpty()) {
response.replaceHeader(header(CONTENT_TYPE.toString(), contentType + "; charset=utf-8"));
}
writeResponse(request, response, true);
}
代码示例来源:origin: jamesdbloom/mockserver
httpResponse.replaceHeader(CONTENT_LENGTH.toString(), String.valueOf(length * 2));
} else if (error == EchoServer.Error.SMALLER_CONTENT_LENGTH) {
httpResponse.replaceHeader(CONTENT_LENGTH.toString(), String.valueOf(length / 2));
} else {
httpResponse.replaceHeader(CONTENT_LENGTH.toString(), String.valueOf(length));
代码示例来源:origin: jamesdbloom/mockserver
protected void addConnectionHeader(HttpRequest request, HttpResponse response) {
ConnectionOptions connectionOptions = response.getConnectionOptions();
if (connectionOptions != null && connectionOptions.getKeepAliveOverride() != null) {
if (connectionOptions.getKeepAliveOverride()) {
response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString()));
} else {
response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString()));
}
} else if (connectionOptions == null || isFalseOrNull(connectionOptions.getSuppressConnectionHeader())) {
if (request.isKeepAlive() != null && request.isKeepAlive()
&& (connectionOptions == null || isFalseOrNull(connectionOptions.getCloseSocket()))) {
response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString()));
} else {
response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString()));
}
}
}
}
代码示例来源:origin: org.mock-server/mockserver-netty
@Override
public void writeResponse(HttpRequest request, HttpResponseStatus responseStatus, String body, String contentType) {
HttpResponse response = response()
.withStatusCode(responseStatus.code())
.withBody(body);
if (body != null && !body.isEmpty()) {
response.replaceHeader(header(CONTENT_TYPE.toString(), contentType + "; charset=utf-8"));
}
writeResponse(request, response, true);
}
代码示例来源:origin: org.mock-server/mockserver-core
@Override
public void writeResponse(HttpRequest request, HttpResponseStatus responseStatus, String body, String contentType) {
HttpResponse response = response()
.withStatusCode(responseStatus.code())
.withReasonPhrase(responseStatus.reasonPhrase())
.withBody(body);
if (body != null && !body.isEmpty()) {
response.replaceHeader(header(CONTENT_TYPE.toString(), contentType + "; charset=utf-8"));
}
writeResponse(request, response, true);
}
代码示例来源:origin: org.mock-server/mockserver-core
httpResponse.replaceHeader(CONTENT_LENGTH.toString(), String.valueOf(length * 2));
} else if (error == EchoServer.Error.SMALLER_CONTENT_LENGTH) {
httpResponse.replaceHeader(CONTENT_LENGTH.toString(), String.valueOf(length / 2));
} else {
httpResponse.replaceHeader(CONTENT_LENGTH.toString(), String.valueOf(length));
代码示例来源:origin: org.mock-server/mockserver-core
protected void addConnectionHeader(HttpRequest request, HttpResponse response) {
ConnectionOptions connectionOptions = response.getConnectionOptions();
if (connectionOptions != null && connectionOptions.getKeepAliveOverride() != null) {
if (connectionOptions.getKeepAliveOverride()) {
response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString()));
} else {
response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString()));
}
} else if (connectionOptions == null || isFalseOrNull(connectionOptions.getSuppressConnectionHeader())) {
if (request.isKeepAlive() != null && request.isKeepAlive()
&& (connectionOptions == null || isFalseOrNull(connectionOptions.getCloseSocket()))) {
response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString()));
} else {
response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString()));
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!