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

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

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

HttpRequest.url介绍

[英]Returns full URL path. Simply concatenates #protocol(String), #host(String), #port(int), #path(String) and #queryString(String).
[中]返回完整的URL路径。简单地连接#协议(字符串)、#主机(字符串)、#端口(int)、#路径(字符串)和#查询字符串(字符串)。

代码示例

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

/**
 * Opens a new {@link jodd.http.HttpConnection connection}
 * using given {@link jodd.http.HttpConnectionProvider}.
 */
public HttpRequest open(final HttpConnectionProvider httpConnectionProvider) {
  if (this.httpConnection != null) {
    throw new HttpException("Connection already opened");
  }
  try {
    this.httpConnectionProvider = httpConnectionProvider;
    this.httpConnection = httpConnectionProvider.createHttpConnection(this);
  } catch (IOException ioex) {
    throw new HttpException("Can't connect to: " + url(), ioex);
  }
  return this;
}

代码示例来源: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

@Test
void test394() {
  HttpRequest request = HttpRequest.get("https://jodd.org/random link");
  assertEquals("GET", request.method());
  assertEquals("https://jodd.org/random link", request.url());
  request = HttpRequest.get("https://jodd.org/random link?q=1");
  assertEquals("1", request.query().get("q"));
  String badUrl = "httpsjodd.org/random link?q=1:// GET";
  try {				
    HttpRequest.get(badUrl).send();
    fail("error");
  }
  catch (HttpException he) {
    assertTrue(he.getMessage().contains(badUrl));
  }
}

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

/**
 * Opens a new {@link jodd.http.HttpConnection connection}
 * using given {@link jodd.http.HttpConnectionProvider}.
 */
public HttpRequest open(final HttpConnectionProvider httpConnectionProvider) {
  if (this.httpConnection != null) {
    throw new HttpException("Connection already opened");
  }
  try {
    this.httpConnectionProvider = httpConnectionProvider;
    this.httpConnection = httpConnectionProvider.createHttpConnection(this);
  } catch (IOException ioex) {
    throw new HttpException("Can't connect to: " + url(), ioex);
  }
  return this;
}

相关文章