Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.StatusLine


    public HttpResponse readResponse() throws IOException
    {
        try
        {
            String line = readLine();
            return new HttpResponse(new StatusLine(line), HttpParser.parseHeaders(this.in, encoding), this.in);
        }
        catch (IOException e)
        {
            close();
            throw e;
View Full Code Here


    Multival outHeaders = new Multival();
    for (Header header : responseHeaders) {
      outHeaders.add(header.getName(), header.getValue());
    }
    StatusLine statusLine = httpMethod.getStatusLine();

    InputStream responseStream = httpMethod.getResponseBodyAsStream();

    HttpClient3Response response = new HttpClient3Response(statusCode, statusLine.getReasonPhrase(), outHeaders,
        responseStream, httpMethod);
    return response;
  }
View Full Code Here

    public void mockConnection(String responseBody) throws Exception {
   

        InputStream is = new ByteArrayInputStream(responseBody.getBytes());
        StatusLine statusLine = new StatusLine("HTTP/1.1 200 OK");

    this.httpMethodMock = mock(HttpMethod.class);
    
        when(httpMethodMock.getStatusLine()).thenReturn(statusLine);
        when(httpMethodMock.getStatusCode()).thenReturn(200);
View Full Code Here

              method.setQueryString("digitalAssetId=" + digitalAssetId);
              method.setFollowRedirects(true);
 
              // execute the method
              client.executeMethod(method);
              StatusLine status = method.getStatusLine();
              if (status != null && status.getStatusCode() == 200) {
                  log.info("Successfully deployed portlet at " + url);
              } else {
                  log.warn("Failed to deploy portlet at " + url + ": " + status);
              }
 
View Full Code Here

        if (statusCode >= 400 && statusCode != 401 & statusCode != 403)
        {
            //FIXME: Why do this only for HTTP Proxy? Why not WebServices?
            if (!context.isSoapRequest())
            {
                StatusLine statusLine = context.getHttpMethod().getStatusLine();
                String reason = null;

                if (statusLine != null)
                {
                    reason = statusLine.toString();
                }

                if (reason == null || "".equals(reason))
                {
                    reason = "" + statusCode;
View Full Code Here

        int statusCode = 200;

        boolean customAuth = target.useCustomAuthentication();

        StatusLine statusLine = context.getHttpMethod().getStatusLine();
        if (statusLine != null)
        {
            statusCode = statusLine.getStatusCode();
        }

        context.setStatusCode(statusCode);

        if (statusCode == 401 || statusCode == 403)
        {
            if (!customAuth)
            {
                if (!context.isHttpRequest())
                {
                    throw new ProxyException(NO_BASIC_NOT_HTTP);
                }
                else if (context.isSoapRequest())
                {
                    // Note: if we remove this error, must do the proxyDomain/targetHost check as done above
                    throw new ProxyException(NO_BASIC_FOR_SOAP);
                }
                else
                {
                    // Don't allow a 401 (and 403, although this should never happen) to be sent to the client
                    // if the service is not using custom authentication and the domains do not match

                    if (!context.isLocalDomainAndPort())
                    {
                        HttpServletRequest clientRequest = FlexContext.getHttpRequest();

                        String errorMessage = ProxyConstants.DOMAIN_ERROR + " . The proxy domain:port is " +
                                clientRequest.getServerName() + ":" + clientRequest.getServerPort() +
                                " and the target domain:port is " + targetHost + ":" + target.getUrl().getPort();

                        Log.getLogger(HTTPProxyService.LOG_CATEGORY).error(errorMessage);

                        throw new ProxyException(DOMAIN_ERROR);
                    }
                    else
                    {
                        //For BASIC Auth, send back the status code
                        HttpServletResponse clientResponse = FlexContext.getHttpResponse();
                        clientResponse.setStatus(statusCode);
                    }
                }
            }
            else
            {
                String message = null;
                if (statusLine != null)
                    message = statusLine.toString();

                if (statusCode == 401)
                {
                    ProxyException se = new ProxyException();
                    se.setCode("Client.Authentication");
View Full Code Here

            if (line == null) {
                setKeepAlive(false);
                return null;
            }
            SimpleResponse response = new SimpleResponse(
                    new StatusLine(line),
                    HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                    this.in);
            return response;
        } catch (IOException e) {
            close();
View Full Code Here

            gm.setFollowRedirects( true );

            cl.executeMethod( gm );

            StatusLine sl = gm.getStatusLine();

            if ( sl == null )
            {
                getLog().error( "Unknown error validating link: " + link );
View Full Code Here

            // We want to do it manually
            hm.setFollowRedirects( false );
            URL url = new URL( link );
            cl.getHostConfiguration().setHost( url.getHost(), url.getPort(), url.getProtocol() );
            cl.executeMethod( hm );
            StatusLine sl = hm.getStatusLine();

            if ( sl == null )
            {
                LOG.error( "Unknown error validating link : " + link );
                return null;
View Full Code Here

            if (line == null) {
                setKeepAlive(false);
                return null;
            }
            SimpleResponse response = new SimpleResponse(
                    new StatusLine(line),
                    HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                    this.in);
            return response;
        } catch (IOException e) {
            close();
View Full Code Here

TOP

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

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.