jodd.http.HttpRequest.set()方法的使用及代码示例

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

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

HttpRequest.set介绍

[英]Sets the destination (method, host, port... ) at once.
[中]设置目标(方法、主机、端口…)同时

代码示例

代码示例来源:origin: oblac/jodd

/**
 * Generic request builder, usually used when method is a variable.
 * Otherwise, use one of the other static request builder methods.
 */
public static HttpRequest create(final String method, final String destination) {
  return new HttpRequest()
      .method(method.toUpperCase())
      .set(destination);
}

代码示例来源:origin: oblac/jodd

/**
 * Builds a DELETE request.
 */
public static HttpRequest delete(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.DELETE)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds an OPTIONS request.
 */
public static HttpRequest options(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.OPTIONS)
      .set(destination);
}

代码示例来源:origin: oblac/jodd

/**
 * Builds a GET request.
 */
public static HttpRequest get(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.GET)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds a CONNECT request.
 */
public static HttpRequest connect(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.CONNECT)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds a PUT request.
 */
public static HttpRequest put(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.PUT)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds a PATCH request.
 */
public static HttpRequest patch(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.PATCH)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds a HEAD request.
 */
public static HttpRequest head(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.HEAD)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds a POST request.
 */
public static HttpRequest post(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.POST)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * Builds a TRACE request.
 */
public static HttpRequest trace(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.TRACE)
      .set(destination);
}
/**

代码示例来源:origin: oblac/jodd

/**
 * {@link #open() Opens connection} if not already open, sends request,
 * reads response and closes the request. If keep-alive mode is enabled
 * connection will not be closed.
 */
public HttpResponse send() {
  if (!followRedirects) {
    return _send();
  }
  int redirects = this.maxRedirects;
  while (redirects > 0) {
    redirects--;
    final HttpResponse httpResponse = _send();
    final int statusCode = httpResponse.statusCode();
    if (HttpStatus.isRedirect(statusCode)) {
      _reset();
      set(httpResponse.location());
      continue;
    }
    return httpResponse;
  }
  throw new HttpException("Max number of redirects exceeded: " + this.maxRedirects);
}

代码示例来源:origin: oblac/jodd

@Test
void testUrl() {
  HttpRequest httpRequest = new HttpRequest();
  httpRequest.set("GET http://jodd.org:173/index.html?light=true");
  assertEquals("http://jodd.org:173/index.html?light=true", httpRequest.url());
  assertEquals("http://jodd.org:173", httpRequest.hostUrl());
  httpRequest = HttpRequest.get("foo.com/");
  assertEquals("http://foo.com", httpRequest.hostUrl());
}

代码示例来源:origin: oblac/jodd

httpRequest = new HttpRequest()
    .method(originalMethod)
    .set(newPath);
continue;

代码示例来源:origin: oblac/jodd

@Test
void testSet() {
  HttpRequest httpRequest = new HttpRequest();
  httpRequest.set("GET http://jodd.org:173/index.html?light=true");
  httpRequest.set("http://jodd.org:173/index.html?light=true");
  httpRequest.set("jodd.org:173/index.html?light=true");
  httpRequest.set("jodd.org/index.html?light=true");
  httpRequest.set("/index.html?light=true");
  httpRequest.set("http://jodd.org");

代码示例来源:origin: org.jodd/jodd-http

/**
 * Generic request builder, usually used when method is a variable.
 * Otherwise, use one of the other static request builder methods.
 */
public static HttpRequest create(final String method, final String destination) {
  return new HttpRequest()
      .method(method.toUpperCase())
      .set(destination);
}

代码示例来源:origin: org.jodd/jodd-http

/**
 * Builds a POST request.
 */
public static HttpRequest post(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.POST)
      .set(destination);
}
/**

代码示例来源:origin: org.jodd/jodd-http

/**
 * Builds a HEAD request.
 */
public static HttpRequest head(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.HEAD)
      .set(destination);
}
/**

代码示例来源:origin: org.jodd/jodd-http

/**
 * Builds a GET request.
 */
public static HttpRequest get(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.GET)
      .set(destination);
}
/**

代码示例来源:origin: org.jodd/jodd-http

/**
 * Builds a PUT request.
 */
public static HttpRequest put(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.PUT)
      .set(destination);
}
/**

代码示例来源:origin: org.jodd/jodd-http

/**
 * Builds an OPTIONS request.
 */
public static HttpRequest options(final String destination) {
  return new HttpRequest()
      .method(HttpMethod.OPTIONS)
      .set(destination);
}

相关文章