本文整理了Java中org.mockserver.model.HttpResponse.getConnectionOptions()
方法的一些代码示例,展示了HttpResponse.getConnectionOptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getConnectionOptions()
方法的具体详情如下:
包路径:org.mockserver.model.HttpResponse
类名称:HttpResponse
方法名:getConnectionOptions
暂无
代码示例来源:origin: jamesdbloom/mockserver
private void writeAndCloseSocket(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response) {
boolean closeChannel;
ConnectionOptions connectionOptions = response.getConnectionOptions();
if (connectionOptions != null && connectionOptions.getCloseSocket() != null) {
closeChannel = connectionOptions.getCloseSocket();
} else {
closeChannel = !(request.isKeepAlive() != null && request.isKeepAlive());
}
if (closeChannel) {
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
ctx.writeAndFlush(response);
}
}
代码示例来源:origin: jamesdbloom/mockserver
jgen.writeObjectField("delay", httpResponse.getDelay());
if (httpResponse.getConnectionOptions() != null) {
jgen.writeObjectField("connectionOptions", httpResponse.getConnectionOptions());
代码示例来源:origin: jamesdbloom/mockserver
public HttpResponseDTO(HttpResponse httpResponse) {
if (httpResponse != null) {
statusCode = httpResponse.getStatusCode();
reasonPhrase = httpResponse.getReasonPhrase();
body = BodyWithContentTypeDTO.createDTO(httpResponse.getBody());
headers = httpResponse.getHeaders();
cookies = httpResponse.getCookies();
delay = (httpResponse.getDelay() != null ? new DelayDTO(httpResponse.getDelay()) : null);
connectionOptions = (httpResponse.getConnectionOptions() != null ? new ConnectionOptionsDTO(httpResponse.getConnectionOptions()) : null);
}
}
代码示例来源:origin: jamesdbloom/mockserver
appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output).append(".withDelay(").append(new DelayToJavaSerializer().serialize(0, httpResponse.getDelay())).append(")");
if (httpResponse.getConnectionOptions() != null) {
appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output).append(".withConnectionOptions(");
output.append(new ConnectionOptionsToJavaSerializer().serialize(numberOfSpacesToIndent + 2, httpResponse.getConnectionOptions()));
appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output).append(")");
代码示例来源:origin: jamesdbloom/mockserver
private boolean validateSupportedFeatures(Expectation expectation, HttpRequest request, ResponseWriter responseWriter) {
boolean valid = true;
Action action = expectation.getAction();
String NOT_SUPPORTED_MESSAGE = " is not supported by MockServer deployed as a WAR due to limitations in the JEE specification; use mockserver-netty to enable these features";
if (action instanceof HttpResponse && ((HttpResponse) action).getConnectionOptions() != null) {
valid = false;
responseWriter.writeResponse(request, response("ConnectionOptions" + NOT_SUPPORTED_MESSAGE), true);
} else if (action instanceof HttpObjectCallback) {
valid = false;
responseWriter.writeResponse(request, response("HttpObjectCallback" + NOT_SUPPORTED_MESSAGE), true);
} else if (action instanceof HttpError) {
valid = false;
responseWriter.writeResponse(request, response("HttpError" + NOT_SUPPORTED_MESSAGE), true);
}
return valid;
}
代码示例来源:origin: jamesdbloom/mockserver
ConnectionOptions connectionOptions = response.getConnectionOptions();
boolean overrideContentLength = connectionOptions != null && connectionOptions.getContentLengthHeaderOverride() != null;
boolean addContentLength = connectionOptions == null || isFalseOrNull(connectionOptions.getSuppressContentLengthHeader());
代码示例来源: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
private void writeAndCloseSocket(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response) {
boolean closeChannel;
ConnectionOptions connectionOptions = response.getConnectionOptions();
if (connectionOptions != null && connectionOptions.getCloseSocket() != null) {
closeChannel = connectionOptions.getCloseSocket();
} else {
closeChannel = !(request.isKeepAlive() != null && request.isKeepAlive());
}
if (closeChannel) {
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} else {
ctx.writeAndFlush(response);
}
}
代码示例来源:origin: org.mock-server/mockserver-core
jgen.writeObjectField("delay", httpResponse.getDelay());
if (httpResponse.getConnectionOptions() != null) {
jgen.writeObjectField("connectionOptions", httpResponse.getConnectionOptions());
代码示例来源:origin: org.mock-server/mockserver-core
public HttpResponseDTO(HttpResponse httpResponse) {
if (httpResponse != null) {
statusCode = httpResponse.getStatusCode();
reasonPhrase = httpResponse.getReasonPhrase();
body = BodyWithContentTypeDTO.createDTO(httpResponse.getBody());
headers = httpResponse.getHeaders();
cookies = httpResponse.getCookies();
delay = (httpResponse.getDelay() != null ? new DelayDTO(httpResponse.getDelay()) : null);
connectionOptions = (httpResponse.getConnectionOptions() != null ? new ConnectionOptionsDTO(httpResponse.getConnectionOptions()) : null);
}
}
代码示例来源:origin: org.mock-server/mockserver-core
appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output).append(".withDelay(").append(new DelayToJavaSerializer().serialize(0, httpResponse.getDelay())).append(")");
if (httpResponse.getConnectionOptions() != null) {
appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output).append(".withConnectionOptions(");
output.append(new ConnectionOptionsToJavaSerializer().serialize(numberOfSpacesToIndent + 2, httpResponse.getConnectionOptions()));
appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output).append(")");
代码示例来源:origin: org.mock-server/mockserver-core
private boolean validateSupportedFeatures(Expectation expectation, HttpRequest request, ResponseWriter responseWriter) {
boolean valid = true;
Action action = expectation.getAction();
String NOT_SUPPORTED_MESSAGE = " is not supported by MockServer deployed as a WAR due to limitations in the JEE specification; use mockserver-netty to enable these features";
if (action instanceof HttpResponse && ((HttpResponse) action).getConnectionOptions() != null) {
responseWriter.writeResponse(request, response("ConnectionOptions" + NOT_SUPPORTED_MESSAGE), true);
valid = false;
} else if (action instanceof HttpObjectCallback) {
responseWriter.writeResponse(request, response("HttpObjectCallback" + NOT_SUPPORTED_MESSAGE), true);
valid = false;
} else if (action instanceof HttpError) {
responseWriter.writeResponse(request, response("HttpError" + NOT_SUPPORTED_MESSAGE), true);
valid = false;
}
return valid;
}
代码示例来源:origin: org.mock-server/mockserver-core
ConnectionOptions connectionOptions = response.getConnectionOptions();
boolean overrideContentLength = connectionOptions != null && connectionOptions.getContentLengthHeaderOverride() != null;
boolean addContentLength = connectionOptions == null || isFalseOrNull(connectionOptions.getSuppressContentLengthHeader());
代码示例来源: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()));
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!