Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.URI


    @Override
    public void setUp() throws Exception {
        super.setUp();
        this.cacheManager = new CacheManager();
        this.currentTimeInGMT = makeDate(new Date());
        this.uri = new URI(LOCAL_HOST, false);
        this.url = new URL(LOCAL_HOST);
        this.urlConnection =  new URLConnectionStub(this.url.openConnection());
        this.httpMethod = new HttpMethodStub();
        this.httpUrlConnection = new HttpURLConnectionStub(this.httpMethod, this.url);
        this.sampleResultOK = getSampleResultWithSpecifiedResponseCode("200");
View Full Code Here


        } catch (ParserConfigurationException e) {
            throw new RepositoryException(e);
        }

        try {
            URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri+"/", true);
            hostConfig = new HostConfiguration();
            hostConfig.setHost(repositoryUri);

            nsCache = new NamespaceCache();
            uriResolver = new URIResolverImpl(repositoryUri, this, domFactory);
View Full Code Here

        hostConfig = setupSocksProxy(settings, hostConfig);
        Object[] authSettings = setupHttpProxy(settings, hostConfig);
        hostConfig = (HostConfiguration) authSettings[0];

        try {
            hostConfig.setHost(new URI(escapeUri(host, settings.getNetworkSSLEnabled()), false));
        } catch (IOException ex) {
            throw new EsHadoopTransportException("Invalid target URI " + host, ex);
        }
        client = new HttpClient(params, new SocketTrackingConnectionManager());
        client.setHostConfiguration(hostConfig);
View Full Code Here

            throw new EsHadoopTransportException("Unknown request method " + request.method());
        }

        CharSequence uri = request.uri();
        if (StringUtils.hasText(uri)) {
            http.setURI(new URI(escapeUri(uri.toString(), settings.getNetworkSSLEnabled()), false));
        }
        // NB: initialize the path _after_ the URI otherwise the path gets reset to /
        http.setPath(prefixPath(request.path().toString()));

        try {
View Full Code Here

    private void httpProxy(
        final SimpleHttpServerConnection conn,
        final SimpleRequest request) throws IOException {

        RequestLine oldreqline = request.getRequestLine();
        URI uri = new URI(oldreqline.getUri(), true);
        SimpleHost host = new SimpleHost(uri.getHost(), uri.getPort());
        SimpleHttpServerConnection proxyconn = this.connmanager.openConnection(host);
        proxyconn.setSocketTimeout(0);
        try {

           
            // Rewrite target url
            RequestLine newreqline = new RequestLine(
                    oldreqline.getMethod(),
                    uri.getEscapedPath(),
                    oldreqline.getHttpVersion());
            request.setRequestLine(newreqline);
            // Remove proxy-auth headers if present
            request.removeHeaders("Proxy-Authorization");
            // Manage connection persistence
View Full Code Here

      }
    }
  }

  private static int httpNotification(String uri) throws IOException {
    URI url = new URI(uri, false);
    HttpClient m_client = new HttpClient();
    HttpMethod method = new GetMethod(url.getEscapedURI());
    method.setRequestHeader("Accept", "*/*");
    return m_client.executeMethod(method);
  }
View Full Code Here

        final SimpleHttpServerConnection conn,
        final SimpleRequest request) throws IOException
    {
        Log wireLog = LogFactory.getLog("httpclient.wire");
       
        URI url = new HttpURL(request.getRequestLine().getUri());

        HttpClient client = new HttpClient();
        HostConfiguration hc = new HostConfiguration();
        hc.setHost(url);
        client.setHostConfiguration(hc);
       
        //TODO support other methods
        HttpMethod method = new GetMethod(url.getPathQuery());
        Header[] headers = request.getHeaders();
        for (int i=0; i<headers.length; i++) {
            method.addRequestHeader(headers[i]);
        }
        if (method instanceof EntityEnclosingMethod) {
View Full Code Here

    }

    public void testGetWithCookies() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/cookie", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Cookie", "$Version=\"1\";login=\"jdoe\"");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here

    }

    public void testGetWithLanguage() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/language", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Content-Language", "en-us");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here

    }

    public void testGetWithContent() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/content", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Content-Type", "application/html");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.URI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.