org.apache.jmeter.protocol.http.sampler

## Class PostWriter

- java.lang.Object
- - org.apache.jmeter.protocol.http.sampler.PostWriter

- Direct Known Subclasses:
    PutWriter

      public class PostWriter
      extends java.lang.Object

  Class for setting the necessary headers for a POST request, and sending the body of the POST.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `BOUNDARY` The boundary string between multiparts
    `static java.lang.String` | `ENCODING`
    `protected byte[]` | `formDataPostBody` The form data that is going to be sent in post body
    `protected byte[]` | `formDataUrlEncoded` The form data that is going to be sent as url encoded

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PostWriter()` Constructor for PostWriter.
    `PostWriter(java.lang.String boundary)` Constructor for PostWriter

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.lang.String` | `getBoundary()` Get the boundary string, used to separate multiparts
    `java.lang.String` | `sendPostData(java.net.URLConnection connection, HTTPSamplerBase sampler)` Send POST data from Entry to the open connection.
    `void` | `setHeaders(java.net.URLConnection connection, HTTPSamplerBase sampler)`

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

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

- - ### Field Detail

    - #### BOUNDARY

          protected static final java.lang.String BOUNDARY

      The boundary string between multiparts
      See Also:
        Constant Field Values

    - #### ENCODING

          public static final java.lang.String ENCODING

    - #### formDataUrlEncoded

          protected byte[] formDataUrlEncoded

      The form data that is going to be sent as url encoded

    - #### formDataPostBody

          protected byte[] formDataPostBody

      The form data that is going to be sent in post body

  - ### Constructor Detail

    - #### PostWriter

          public PostWriter()

      Constructor for PostWriter. Uses the PostWriter.BOUNDARY as the boundary string

    - #### PostWriter

          public PostWriter(java.lang.String boundary)

      Constructor for PostWriter
      Parameters:
        `boundary` - the boundary string to use as marker between multipart parts

  - ### Method Detail

    - #### sendPostData

          public java.lang.String sendPostData(java.net.URLConnection connection,
                                               HTTPSamplerBase sampler)
                                        throws java.io.IOException

      Send POST data from Entry to the open connection.
      Parameters:
        `connection` - the open connection to use for sending data
        `sampler` - sampler to get information about what to send
      Returns:
        the post body sent. Actual file content is not returned, it is just shown as a placeholder text "actual file content"
      Throws:
        `java.io.IOException` - when writing data fails

    - #### setHeaders

          public void setHeaders(java.net.URLConnection connection,
                                 HTTPSamplerBase sampler)
                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getBoundary

          protected java.lang.String getBoundary()

      Get the boundary string, used to separate multiparts
      Returns:
        the boundary string

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.