public CommonXmlRpcClient(AbstractWebLocation location, HttpClient client) {
   this.location = location;
   this.httpClient = createHttpClient(DEFAULT_USER_AGENT);
   this.authScope =
       new AuthScope(
           WebUtil.getHost(location.getUrl()),
           WebUtil.getPort(location.getUrl()),
           null,
           AuthScope.ANY_SCHEME);
 }
Exemplo n.º 2
0
  public void testUrlParsers() {
    String url = "https://example.com:444/folder/file.txt";
    assertEquals(444, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals("/folder/file.txt", WebUtil.getRequestPath(url));

    url = "http://example.com/";
    assertEquals(80, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals("/", WebUtil.getRequestPath(url));

    url = "http://example.com";
    assertEquals(80, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals("", WebUtil.getRequestPath(url));

    url = "https://example.com:321";
    assertEquals(321, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals("", WebUtil.getRequestPath(url));

    url = "example.com:321";
    assertEquals(321, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals("", WebUtil.getRequestPath(url));

    url = "https://example.com:444/folder/file.txt?search=https://example.com:812/folder/file.txt";
    assertEquals(444, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals(
        "/folder/file.txt?search=https://example.com:812/folder/file.txt",
        WebUtil.getRequestPath(url));

    url = "https://example.com/folder/file.txt?search=https://example.com:812/folder/file.txt";
    assertEquals(443, WebUtil.getPort(url));
    assertEquals("example.com", WebUtil.getHost(url));
    assertEquals(
        "/folder/file.txt?search=https://example.com:812/folder/file.txt",
        WebUtil.getRequestPath(url));

    url =
        "https://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?&pid=11093&resolution=-1&sorter/field=updated&sorter/order=DESC&tempMax=1000";
    assertEquals(443, WebUtil.getPort(url));
    assertEquals("jira.codehaus.org", WebUtil.getHost(url));
    assertEquals(
        "/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?&pid=11093&resolution=-1&sorter/field=updated&sorter/order=DESC&tempMax=1000",
        WebUtil.getRequestPath(url));
  }