Class HttpRequestBodyMultipartBuilder

java.lang.Object
com.github.mjeanroy.junit.servers.client.HttpRequestBodyMultipartBuilder

public final class HttpRequestBodyMultipartBuilder extends Object
A builder for HttpRequestBodyMultipart request.
  • Method Details

    • withBoundaries

      public HttpRequestBodyMultipartBuilder withBoundaries(String boundaries)
      Define new boundaries value.
      Parameters:
      boundaries - New boundaries
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(HttpRequestBody body, String name)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>".
      Parameters:
      body - Part body.
      name - The name attribute of COntent-Disposition header.
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(HttpRequestBody body, String name, String filename)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>".
      Parameters:
      body - Part body.
      name - The name attribute of Content-Disposition header.
      filename - The filename attribute Content-Disposition header.
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(String name, String value)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>".
      Parameters:
      name - The name attribute of COntent-Disposition header.
      value - Part raw value.
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(File file, String name)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>"; filename="<filename>". The name of the file in parameter will be automatically used as the filename attribute of Content-Disposition header.
      Parameters:
      file - The file being sent.
      name - The name attribute of COntent-Disposition header.
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(File file, String name, String filename)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>"; filename="<filename>".
      Parameters:
      file - The file being sent.
      name - The name attribute of COntent-Disposition header.
      filename - The filename attribute Content-Disposition header.
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(Path path, String name)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>"; filename="<filename>".
      Parameters:
      path - The file being sent.
      name - The name attribute of COntent-Disposition header.
      Returns:
      The builder.
    • addFormDataPart

      public HttpRequestBodyMultipartBuilder addFormDataPart(Path path, String name, String filename)
      Add "form-data" part. Instead of a "simple" part, a Content-Disposition header will be automatically added with this part, such as: Content-Disposition: form-data; name="<name>"; filename="<filename>".
      Parameters:
      path - The file being sent.
      name - The name attribute of COntent-Disposition header.
      filename - The filename attribute COntent-Disposition header.
      Returns:
      The builder.
    • addPart

      Add part to request body.
      Parameters:
      part - Part to add.
      Returns:
      The builder.
    • asMultipartFormData

      public HttpRequestBodyMultipartBuilder asMultipartFormData()
      Update content-type to "multipart/form-data".
      Returns:
      The builder.
    • asMultipartMixed

      public HttpRequestBodyMultipartBuilder asMultipartMixed()
      Update content-type to "multipart/mixed".
      Returns:
      The builder.
    • asMultipartAlternative

      public HttpRequestBodyMultipartBuilder asMultipartAlternative()
      Update content-type to "multipart/alternative".
      Returns:
      The builder.
    • asMultipartDigest

      public HttpRequestBodyMultipartBuilder asMultipartDigest()
      Update content-type to "multipart/digest".
      Returns:
      The builder.
    • asMultipartParallel

      public HttpRequestBodyMultipartBuilder asMultipartParallel()
      Update content-type to "multipart/parallel".
      Returns:
      The builder.
    • build

      public HttpRequestBody build()
      Build multipart body.
      Returns:
      The multipart body.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object