org.apache.ode.axis2.httpbinding

## Class HttpHelper

- java.lang.Object
- - org.apache.ode.axis2.httpbinding.HttpHelper

-     public class HttpHelper
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpHelper()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `configure(org.apache.commons.httpclient.HttpClient client, org.apache.commons.httpclient.URI targetURI, org.w3c.dom.Element authPart, org.apache.commons.httpclient.params.HttpParams params)`
    `static int` | `isFaultOrFailure(int s)`
    `static org.w3c.dom.Element` | `prepareDetailsElement(org.apache.commons.httpclient.HttpMethod method)` Build a "details" element that looks like this:
    `static java.lang.String` | `replaceCRLFwithLWS(java.lang.String header)` This method ensures that a header value containing CRLF does not mess up the HTTP request.
    `static java.lang.String` | `requestToString(org.apache.commons.httpclient.HttpMethod m)`
    `static java.lang.String` | `responseToString(org.apache.commons.httpclient.HttpMethod m)`
    `static org.w3c.dom.Element` | `statusLineToElement(org.w3c.dom.Document doc, org.apache.commons.httpclient.StatusLine statusLine)` Convert a HTTP status line into an xml element like this: < Status-line> < HTTP-Version>HTTP/1.1< /HTTP-Version> < Status-Code>200< /Status-Code> < Reason-Phrase>Success - The action was successfully received, understood, and accepted< /Reason-Phrase> < /Status-line>
    `static org.w3c.dom.Element` | `statusLineToElement(org.apache.commons.httpclient.StatusLine statusLine)`
    `static org.w3c.dom.Element` | `statusLineToElement(java.lang.String statusLine)` Parse and convert a HTTP status line into an aml element.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpHelper

          public HttpHelper()

  - ### Method Detail

    - #### configure

          public static void configure(org.apache.commons.httpclient.HttpClient client,
                       org.apache.commons.httpclient.URI targetURI,
                       org.w3c.dom.Element authPart,
                       org.apache.commons.httpclient.params.HttpParams params)
                                throws org.apache.commons.httpclient.URIException

      Throws:
        `org.apache.commons.httpclient.URIException`

    - #### statusLineToElement

          public static org.w3c.dom.Element statusLineToElement(java.lang.String statusLine)
                                                         throws org.apache.commons.httpclient.HttpException

      Parse and convert a HTTP status line into an aml element.
      Parameters:
        `statusLine` -
      Returns:
      Throws:
        `org.apache.commons.httpclient.HttpException`
      See Also:
        `statusLineToElement(org.w3c.dom.Document, org.apache.commons.httpclient.StatusLine)`

    - #### statusLineToElement

          public static org.w3c.dom.Element statusLineToElement(org.apache.commons.httpclient.StatusLine statusLine)

    - #### statusLineToElement

          public static org.w3c.dom.Element statusLineToElement(org.w3c.dom.Document doc,
                                                org.apache.commons.httpclient.StatusLine statusLine)

      Convert a HTTP status line into an xml element like this:

      < Status-line> < HTTP-Version>HTTP/1.1< /HTTP-Version> < Status-Code>200< /Status-Code> < Reason-Phrase>Success - The action was successfully received, understood, and accepted< /Reason-Phrase> < /Status-line>
      Parameters:
        `statusLine` - - the `StatusLine` instance to be converted
        `doc` - - the document to use to create new nodes
      Returns:
        an Element

    - #### prepareDetailsElement

          public static org.w3c.dom.Element prepareDetailsElement(org.apache.commons.httpclient.HttpMethod method)

      Build a "details" element that looks like this:
      Parameters:
        `method` -
      Returns:
      Throws:
        `java.io.IOException`

    - #### replaceCRLFwithLWS

          public static java.lang.String replaceCRLFwithLWS(java.lang.String header)

      This method ensures that a header value containing CRLF does not mess up the HTTP request. Actually CRLF is the end-of-line marker for headers.

      To do so, all CRLF followed by a non-whitespace character are replaced by CRLF HT.

      This is possible because the Section 2.2 of HTTP standard (RFC2626) states that:

      HTTP/1.1 header field values can be folded onto multiple lines if the continuation line begins with a space or horizontal tab. All linear white space, including folding, has the same semantics as SP. A recipient MAY replace any linear white space with a single SP before interpreting the field value or forwarding the message downstream.

      LWS = [CRLF] 1*( SP | HT )

      FYI, HttpClient 3.x.x does not check this.
      Parameters:
        `header` -
      Returns:
        the string properly ready to be used as an HTTP header field-content

    - #### requestToString

          public static java.lang.String requestToString(org.apache.commons.httpclient.HttpMethod m)

    - #### responseToString

          public static java.lang.String responseToString(org.apache.commons.httpclient.HttpMethod m)

    - #### isFaultOrFailure

          public static int isFaultOrFailure(int s)

      Parameters:
        `s,` - the status code to test, must be in [400, 600[
      Returns:
        1 if fault, -1 if failure, 0 if undetermined