Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.StatusLine


            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


                HttpPlaceholderMethod.PLACEHOLDER.getName());
        assertEquals("Mismatched URI",
                HttpClientDefinitions.PLACEHOLDER_URI_VALUE,
                String.valueOf(HttpPlaceholderMethod.PLACEHOLDER.getURI()));

        StatusLine statusLine = HttpPlaceholderMethod.PLACEHOLDER.getStatusLine();
        assertEquals("Mismatched HTTP version", "HTTP/1.1", statusLine.getHttpVersion());
        assertEquals("Mismatched status code", 500, statusLine.getStatusCode());
    }
View Full Code Here

        return HttpClientDefinitions.PLACEHOLDER_METHOD_NAME;
    }

    @Override
    public int getStatusCode() {
        StatusLine st = getStatusLine();
        return st.getStatusCode();
    }
View Full Code Here

        return st.getStatusCode();
    }

    @Override
    public String getStatusText() {
        StatusLine st = getStatusLine();
        return st.getReasonPhrase();
    }
View Full Code Here

    private HttpMethod createMockHttpMethod(String method, InputStream body, String uri, Header[] headers) throws Exception
    {
        HttpMethod httpMethod = mock(HttpMethod.class);
        when(httpMethod.getName()).thenReturn(method);
        when(httpMethod.getStatusLine()).thenReturn(new StatusLine("HTTP/1.1 200 OK"));
        when(httpMethod.getStatusCode()).thenReturn(HttpConstants.SC_OK);
        when(httpMethod.getURI()).thenReturn(new URI(uri, false));
        when(httpMethod.getResponseHeaders()).thenReturn(headers);
        when(httpMethod.getResponseBodyAsStream()).thenReturn(body);
       
View Full Code Here

     * @see #statusLineToElement(org.w3c.dom.Document, org.apache.commons.httpclient.StatusLine)
     */
    public static Element statusLineToElement
            (String
                    statusLine) throws HttpException {
        return statusLineToElement(new StatusLine(statusLine));
    }
View Full Code Here

     * @see #statusLineToElement(org.w3c.dom.Document, org.apache.commons.httpclient.StatusLine)
     */
    public static Element statusLineToElement
            (String
                    statusLine) throws HttpException {
        return statusLineToElement(new StatusLine(statusLine));
    }
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

        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 (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

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.