Class BodySenderRequestBuilderBaseDefault<T extends BodySenderRequestBuilderBase<?>>

java.lang.Object
org.spincast.plugins.httpclient.builders.HttpRequestBuilderBase<T>
org.spincast.plugins.httpclient.builders.BodySenderRequestBuilderBaseDefault<T>
All Implemented Interfaces:
BodySenderRequestBuilderBase<T>, HttpRequestBuilder<T>
Direct Known Subclasses:
PatchRequestBuilderDefault, PostRequestBuilderDefault, PutRequestBuilderDefault

public abstract class BodySenderRequestBuilderBaseDefault<T extends BodySenderRequestBuilderBase<?>> extends HttpRequestBuilderBase<T> implements BodySenderRequestBuilderBase<T>
Implementation for the builders that can send a body or upload files..
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
  • Constructor Details

  • Method Details

    • getStringBodyEncoding

      protected String getStringBodyEncoding()
    • getFormBodyEncoding

      protected String getFormBodyEncoding()
    • getBodyType

    • getStandardBody

      protected org.spincast.shaded.org.apache.http.HttpEntity getStandardBody()
    • getJsonManager

      protected JsonManager getJsonManager()
    • getXmlManager

      protected XmlManager getXmlManager()
    • getFormBodyFields

      protected Map<String,List<String>> getFormBodyFields()
    • getFileToUploads

      protected List<FileToUpload> getFileToUploads()
    • addFormBodyFieldValue

      public T addFormBodyFieldValue(String name, String value)
      Description copied from interface: BodySenderRequestBuilderBase
      Adds a value to a Form field.

      Keeps the existing values of the field.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      addFormBodyFieldValue in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • setFormBodyField

      public T setFormBodyField(String fieldName, List<String> values)
      Description copied from interface: BodySenderRequestBuilderBase
      Sets a field on the form body, with its values. Each form field may have multiple values.

      Overwrites an existing field of the same name, but keeps the other ones.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      setFormBodyField in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • setFormBodyFields

      public T setFormBodyFields(Map<String,List<String>> formFields)
      Description copied from interface: BodySenderRequestBuilderBase
      Sets fields on the form body.

      A form body can contain more than one fields and each field may have multiple values.

      Overwrites any existing Form fields.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      setFormBodyFields in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • setStringBody

      public T setStringBody(String stringBody, String contentType)
      Description copied from interface: BodySenderRequestBuilderBase
      Sets a String body.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      setStringBody in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • setJsonStringBody

      public T setJsonStringBody(Object object)
      Description copied from interface: BodySenderRequestBuilderBase
      Sets a Json body to be sent.

      The specified object will be converted to a Json's String representation and sent using the application/json Content-Type.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      setJsonStringBody in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • setXmlStringBody

      public T setXmlStringBody(Object object)
      Description copied from interface: BodySenderRequestBuilderBase
      Sets a XML body to be sent.

      The specified object will be converted to XML and sent using the application/xml Content-Type.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      setXmlStringBody in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • setBody

      public T setBody(org.spincast.shaded.org.apache.http.HttpEntity body)
      Description copied from interface: BodySenderRequestBuilderBase
      Sets an custom HttpEntity body to be sent.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      setBody in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • addFileToUploadBody

      public T addFileToUploadBody(String path, String name)
      Description copied from interface: BodySenderRequestBuilderBase
      Adds a file to upload body.

      More than one file can be uploaded at one time. The specified file is added to the existing ones.

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      addFileToUploadBody in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
      Parameters:
      path - the path to the file to upload, on the file system.
      name - the name to use for the uploaded file.
    • addFileToUploadBody

      public T addFileToUploadBody(String path, boolean isClasspathPath, String name)
      Description copied from interface: BodySenderRequestBuilderBase
      Adds a file to upload body.

      More than one file can be uploaded at one time. The specified file is added to the existing ones.

      Only one type of body can be set amongs:

      Only one type of body can be set amongs:

      • Form body
      • String body
      • File to upload body
      • Custom HttpEntity body

      When you set or add something to a new type of body, the existing body is overwritten, if there is one.

      Specified by:
      addFileToUploadBody in interface BodySenderRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
      Parameters:
      path - the path to the file to upload
      isClasspathPath - if true, the path to the file to upload is on the classpath, otherwise, it's on the file system.
      name - the name to use for the uploaded file.
    • convertToNameValuePair

      protected List<org.spincast.shaded.org.apache.http.NameValuePair> convertToNameValuePair(Map<String,List<String>> params)
    • createMethodSpecificHttpRequest

      protected org.spincast.shaded.org.apache.http.client.methods.HttpRequestBase createMethodSpecificHttpRequest(String url)
      Description copied from class: HttpRequestBuilderBase
      Creates the HttpRequestBase depending on the HTTP method.
      Specified by:
      createMethodSpecificHttpRequest in class HttpRequestBuilderBase<T extends BodySenderRequestBuilderBase<?>>
    • getHttpEntityEnclosingRequestBase

      protected abstract org.spincast.shaded.org.apache.http.client.methods.HttpEntityEnclosingRequestBase getHttpEntityEnclosingRequestBase(String url)