cfboom.http.client

Class SimpleClientHttpRequestFactory

lucee.Component
    extended by cfboom.lang.Object
      extended by cfboom.http.client.SimpleClientHttpRequestFactory
All Implemented Interfaces:
ClientHttpRequestFactory

{@link ClientHttpRequestFactory} implementation that uses standard JDK facilities.

Class Attributes:
  • singleton
  •  
  • output : false
  •  
  • displayname : Class SimpleClientHttpRequestFactory
  •  
  • synchronized : false
  •  
  • see : HttpComponentsClientHttpRequestFactory
  •  
  • accessors : false
  •  
  • persistent : false
  •  
  • since : 3.0
  •  
  • author : Juergen Hoeller
  •  
    Property Summary
    type property default serializable required
    any HttpMethod


    • access = public
    • returntype = any
    • inject = HttpMethod@cfboom-http
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init()
    Method Summary
    ClientHttpRequest createRequest(any uri, [HttpMethod httpMethod])
    any openConnection(any theUrl)
         Opens and returns a connection to the given URL.
    void prepareConnection(any connection, string httpMethod)
         Template method for preparing the given {@link HttpURLConnection}.
    void setBufferRequestBody(boolean bufferRequestBody)
         Indicate whether this request factory should buffer the.
    void setChunkSize(numeric chunkSize)
         Set the number of bytes to write in each chunk when not buffering request.
    void setConnectTimeout(numeric connectTimeout)
         Set the underlying URLConnection's connect timeout (in milliseconds).
    void setOutputStreaming(boolean outputStreaming)
         Set if the underlying URLConnection can be set to 'output streaming' mode.
    void setReadTimeout(numeric readTimeout)
         Set the underlying URLConnection's read timeout (in milliseconds).
    void setStandardRequestBody(boolean standardRequestBody)
         Indicate whether this request factory should use ColdFusion HTTP.
     
    Methods inherited from class cfboom.lang.Object
    $equals, getComponentName, getIdentityHashCode, getIdentityString, getMeta, hashCode, toString
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()


    Property Detail

    HttpMethod

    property any HttpMethod

    Attributes:
    access - public
    required - false
    returntype - any
    inject - HttpMethod@cfboom-http
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    createRequest

    public ClientHttpRequest createRequest(any uri, [HttpMethod httpMethod])

    Specified by:
    createRequest in interface ClientHttpRequestFactory
    Parameters:
    uri
    httpMethod

    openConnection

    public any openConnection(any theUrl)

    Opens and returns a connection to the given URL.

    The default implementation uses the given {@linkplain #setProxy(java.net.Proxy) proxy} - if any - to open a connection.

    Parameters:
    theUrl
    Returns:
    the opened connection
    Throws:
    IOException in case of I/O errors

    prepareConnection

    public void prepareConnection(any connection, string httpMethod)

    Template method for preparing the given {@link HttpURLConnection}.

    The default implementation prepares the connection for input and output, and sets the HTTP method.

    Parameters:
    connection
    httpMethod
    Throws:
    IOException in case of I/O errors

    setBufferRequestBody

    public void setBufferRequestBody(boolean bufferRequestBody)

    Indicate whether this request factory should buffer the {@linkplain ClientHttpRequest#getBody() request body} internally.

    Default is {@code true}. When sending large amounts of data via POST or PUT, it is recommended to change this property to {@code false}, so as not to run out of memory. This will result in a {@link ClientHttpRequest} that either streams directly to the underlying {@link HttpURLConnection} (if the {@link org.springframework.http.HttpHeaders#getContentLength() Content-Length} is known in advance), or that will use "Chunked transfer encoding" (if the {@code Content-Length} is not known in advance).

    Parameters:
    bufferRequestBody

    setChunkSize

    public void setChunkSize(numeric chunkSize)

    Set the number of bytes to write in each chunk when not buffering request bodies locally.

    Note that this parameter is only used when {@link #setBufferRequestBody(boolean) bufferRequestBody} is set to {@code false}, and the {@link org.springframework.http.HttpHeaders#getContentLength() Content-Length} is not known in advance.

    Parameters:
    chunkSize

    setConnectTimeout

    public void setConnectTimeout(numeric connectTimeout)

    Set the underlying URLConnection's connect timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.

    Default is the system's default timeout.

    Parameters:
    connectTimeout

    setOutputStreaming

    public void setOutputStreaming(boolean outputStreaming)

    Set if the underlying URLConnection can be set to 'output streaming' mode. Default is {@code true}.

    When output streaming is enabled, authentication and redirection cannot be handled automatically. If output streaming is disabled, the {@link HttpURLConnection#setFixedLengthStreamingMode} and {@link HttpURLConnection#setChunkedStreamingMode} methods of the underlying connection will never be called.

    Parameters:
    outputStreaming

    setReadTimeout

    public void setReadTimeout(numeric readTimeout)

    Set the underlying URLConnection's read timeout (in milliseconds). A timeout value of 0 specifies an infinite timeout.

    Default is the system's default timeout.

    Parameters:
    readTimeout

    setStandardRequestBody

    public void setStandardRequestBody(boolean standardRequestBody)

    Indicate whether this request factory should use ColdFusion HTTP.

    Parameters:
    standardRequestBody