org.mockserver.model.HttpRequest.getMethod()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.mockserver.model.HttpRequest.getMethod()方法的一些代码示例,展示了HttpRequest.getMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getMethod()方法的具体详情如下:
包路径:org.mockserver.model.HttpRequest
类名称:HttpRequest
方法名:getMethod

HttpRequest.getMethod介绍

暂无

代码示例

代码示例来源:origin: jamesdbloom/mockserver

private boolean hasDefaultMethod(HttpRequest request) {
  return Strings.isNullOrEmpty(request.getMethod().getValue()) || request.getMethod().getValue().equalsIgnoreCase("GET");
}

代码示例来源:origin: jamesdbloom/mockserver

curlString.append("'");
if (!hasDefaultMethod(request)) {
  curlString.append(" -X ").append(request.getMethod().getValue());

代码示例来源:origin: jamesdbloom/mockserver

} else {
  if (request != null) {
    boolean methodMatches = Strings.isNullOrEmpty(request.getMethod().getValue()) || matches(context, methodMatcher, request.getMethod());
    boolean pathMatches = Strings.isNullOrEmpty(request.getPath().getValue()) || matches(context, pathMatcher, request.getPath());
    boolean queryStringParametersMatches = matches(context, queryStringParameterMatcher, request.getQueryStringParameters());

代码示例来源:origin: jamesdbloom/mockserver

public static boolean isPreflightRequest(HttpRequest request) {
  final Headers headers = request.getHeaders();
  return request.getMethod().getValue().equals(OPTIONS.name()) &&
    headers.containsEntry(HttpHeaderNames.ORIGIN.toString()) &&
    headers.containsEntry(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD.toString());
}

代码示例来源:origin: jamesdbloom/mockserver

public void renderDashboard(final ChannelHandlerContext ctx, final HttpRequest request) throws Exception {
  HttpResponse response = notFoundResponse();
  if (request.getMethod().getValue().equals("GET")) {
    String path = StringUtils.substringAfter(request.getPath().getValue(), PATH_PREFIX + "/dashboard");
    if (path.isEmpty() || path.equals("/")) {

代码示例来源:origin: jamesdbloom/mockserver

jgen.writeBooleanField("not", httpRequest.getNot());
if (httpRequest.getMethod() != null && !Strings.isNullOrEmpty(httpRequest.getMethod().getValue())) {
  jgen.writeObjectField("method", httpRequest.getMethod());

代码示例来源:origin: jamesdbloom/mockserver

public FullHttpRequest mapMockServerResponseToHttpServletResponse(HttpRequest httpRequest) {
  // method
  HttpMethod httpMethod = HttpMethod.valueOf(httpRequest.getMethod("GET"));
  // the request
  FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, getURI(httpRequest), getBody(httpRequest));
  // headers
  setHeader(httpRequest, request);
  // cookies
  setCookies(httpRequest, request);
  return request;
}

代码示例来源:origin: jamesdbloom/mockserver

appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output);
output.append("request()");
if (!Strings.isNullOrEmpty(request.getMethod().getValue())) {
  appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output);
  output.append(".withMethod(\"").append(request.getMethod().getValue()).append("\")");

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestDTO(HttpRequest httpRequest, Boolean not) {
  super(not);
  if (httpRequest != null) {
    method = httpRequest.getMethod();
    path = httpRequest.getPath();
    headers = httpRequest.getHeaders();
    cookies = httpRequest.getCookies();
    queryStringParameters = httpRequest.getQueryStringParameters();
    body = BodyDTO.createDTO(httpRequest.getBody());
    keepAlive = httpRequest.isKeepAlive();
    secure = httpRequest.isSecure();
  }
}

代码示例来源:origin: jamesdbloom/mockserver

} else if (request.getMethod().getValue().equals("GET") && request.getPath().getValue().startsWith(PATH_PREFIX + "/dashboard")) {
} else if (request.getMethod().getValue().equals("CONNECT")) {

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestTemplateObject(HttpRequest httpRequest) {
  if (httpRequest != null) {
    method = httpRequest.getMethod().getValue();
    path = httpRequest.getPath().getValue();
    for (Header header : httpRequest.getHeaderList()) {
      headers.put(header.getName().getValue(), Lists.transform(header.getValues(), new Function<NottableString, String>() {
        public String apply(NottableString input) {
          return input.getValue();
        }
      }));
    }
    for (Cookie cookie : httpRequest.getCookieList()) {
      cookies.put(cookie.getName().getValue(), cookie.getValue().getValue());
    }
    for (Parameter parameter : httpRequest.getQueryStringParameterList()) {
      queryStringParameters.put(parameter.getName().getValue(), Lists.transform(parameter.getValues(), new Function<NottableString, String>() {
        public String apply(NottableString input) {
          return input.getValue();
        }
      }));
    }
    body = BodyDTO.createDTO(httpRequest.getBody());
    keepAlive = httpRequest.isKeepAlive();
    secure = httpRequest.isSecure();
  }
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequest update(HttpRequest replaceRequest) {
    if (!Strings.isNullOrEmpty(replaceRequest.getMethod().getValue())) {
      withMethod(replaceRequest.getMethod());
    }
    if (!Strings.isNullOrEmpty(replaceRequest.getPath().getValue())) {
      withPath(replaceRequest.getPath());
    }
    for (Header header : replaceRequest.getHeaderList()) {
      getHeaders().replaceEntry(header);
    }
    for (Cookie cookie : replaceRequest.getCookieList()) {
      withCookie(cookie);
    }
    for (Parameter parameter : replaceRequest.getQueryStringParameterList()) {
      getQueryStringParameters().replaceEntry(parameter);
    }
    if (replaceRequest.getBody() != null) {
      withBody(replaceRequest.getBody());
    }
    if (replaceRequest.isSecure() != null) {
      withSecure(replaceRequest.isSecure());
    }
    if (replaceRequest.isKeepAlive() != null) {
      withKeepAlive(replaceRequest.isKeepAlive());
    }
    return this;
  }
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) {
  this.httpRequest = httpRequest;
  this.mockServerLogger = mockServerLogger;
  if (httpRequest != null) {
    withMethod(httpRequest.getMethod());
    withPath(httpRequest.getPath());
    withQueryStringParameters(httpRequest.getQueryStringParameters());
    withBody(httpRequest.getBody());
    withHeaders(httpRequest.getHeaders());
    withCookies(httpRequest.getCookies());
    withKeepAlive(httpRequest.isKeepAlive());
    withSsl(httpRequest.isSecure());
  }
}

代码示例来源:origin: jamesdbloom/mockserver

public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) {
  this.expectation = expectation;
  this.httpRequest = expectation.getHttpRequest();
  this.mockServerLogger = mockServerLogger;
  if (httpRequest != null) {
    withMethod(httpRequest.getMethod());
    withPath(httpRequest.getPath());
    withQueryStringParameters(httpRequest.getQueryStringParameters());
    withBody(httpRequest.getBody());
    withHeaders(httpRequest.getHeaders());
    withCookies(httpRequest.getCookies());
    withKeepAlive(httpRequest.isKeepAlive());
    withSsl(httpRequest.isSecure());
  }
}

代码示例来源:origin: org.mock-server/mockserver-core

private boolean hasDefaultMethod(HttpRequest request) {
  return Strings.isNullOrEmpty(request.getMethod().getValue()) || request.getMethod().getValue().equalsIgnoreCase("GET");
}

代码示例来源:origin: org.mock-server/mockserver-core

public static boolean isPreflightRequest(HttpRequest request) {
  final Headers headers = request.getHeaders();
  return request.getMethod().getValue().equals(OPTIONS.name()) &&
    headers.containsEntry(HttpHeaderNames.ORIGIN.toString()) &&
    headers.containsEntry(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD.toString());
}

代码示例来源:origin: org.mock-server/mockserver-core

public FullHttpRequest mapMockServerResponseToHttpServletResponse(HttpRequest httpRequest) {
  // method
  HttpMethod httpMethod = HttpMethod.valueOf(httpRequest.getMethod("GET"));
  // the request
  FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, getURI(httpRequest), getBody(httpRequest));
  // headers
  setHeader(httpRequest, request);
  // cookies
  setCookies(httpRequest, request);
  return request;
}

代码示例来源:origin: org.mock-server/mockserver-core

public HttpRequestDTO(HttpRequest httpRequest, Boolean not) {
  super(not);
  if (httpRequest != null) {
    method = httpRequest.getMethod();
    path = httpRequest.getPath();
    headers = httpRequest.getHeaders();
    cookies = httpRequest.getCookies();
    queryStringParameters = httpRequest.getQueryStringParameters();
    body = BodyDTO.createDTO(httpRequest.getBody());
    keepAlive = httpRequest.isKeepAlive();
    secure = httpRequest.isSecure();
  }
}

代码示例来源:origin: org.mock-server/mockserver-core

public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) {
  this.httpRequest = httpRequest;
  this.mockServerLogger = mockServerLogger;
  if (httpRequest != null) {
    withMethod(httpRequest.getMethod());
    withPath(httpRequest.getPath());
    withQueryStringParameters(httpRequest.getQueryStringParameters());
    withBody(httpRequest.getBody());
    withHeaders(httpRequest.getHeaders());
    withCookies(httpRequest.getCookies());
    withKeepAlive(httpRequest.isKeepAlive());
    withSsl(httpRequest.isSecure());
  }
}

代码示例来源:origin: org.mock-server/mockserver-core

public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) {
  this.expectation = expectation;
  this.httpRequest = expectation.getHttpRequest();
  this.mockServerLogger = mockServerLogger;
  if (httpRequest != null) {
    withMethod(httpRequest.getMethod());
    withPath(httpRequest.getPath());
    withQueryStringParameters(httpRequest.getQueryStringParameters());
    withBody(httpRequest.getBody());
    withHeaders(httpRequest.getHeaders());
    withCookies(httpRequest.getCookies());
    withKeepAlive(httpRequest.isKeepAlive());
    withSsl(httpRequest.isSecure());
  }
}

相关文章