Class HttpRequestOptions


  • public class HttpRequestOptions
    extends Object
    Options for HttpClient requests
    • Constructor Detail

      • HttpRequestOptions

        public HttpRequestOptions​(String url,
                                  HttpRequestOptions.Method method)
        Constructs HttpRequestOptions instance
        Parameters:
        url - request URL
        method - request method
    • Method Detail

      • setUrl

        public void setUrl​(String url)
        Sets URL used for request
        Parameters:
        url - new request URL
      • getUrl

        public String getUrl()
        Returns URL used for request
        Returns:
        request URL
      • setMethod

        public void setMethod​(HttpRequestOptions.Method method)
        Sets HTTP method used for request
        Parameters:
        method - supported by HttpClient HTTP method
      • getQueryParameters

        public Map<String,​Object> getQueryParameters()
        Returns query parameters of request. The returned value can be used for setting parameters.
        Returns:
        map of query parameters where the key is the parameter name and the value is its parsable into a string value. The value cal also be a Collection of parsable into a string values.
      • getHeaders

        public Map<String,​String> getHeaders()
        Returns headers of request. The returned value can be used for setting parameters.
        Returns:
        map of headers where the key is the header name and the value is the header value
      • setBody

        public void setBody​(Object jsonBody)
        Sets the json body of a request. If there already is a form data body, it will be erased.
        Parameters:
        jsonBody - object that will be automatically converted into a json string
      • setBody

        public void setBody​(Map<String,​Object> fields)
        Sets the form data body of a request. If there already is a json body, it will erased.
        Parameters:
        fields - map of form fields where the key is the name of a field and the value should be an object that can be parsed as a string, but for files you should use HttpRequestOptions.FileStreamField
      • getBodyJson

        public Optional<Object> getBodyJson()
        Returns the json body of a request
        Returns:
        optional object that can contain json body of a request in its object form
      • getBodyFields

        public Optional<Map<String,​Object>> getBodyFields()
        Returns fields of the request form data body
        Returns:
        optional object that can contain a map of form data fields where the key is the name of the field and the value is its value which was set earlier