# FormWriter

<a id="formwriter"></a>

# FormWriter

```cpp
#include <icy/http/form.h>

class FormWriter
```

[Defined in src/http/include/icy/http/form.h:42](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L42)

> **Inherits:** [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection), [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter), [`Startable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#startable)

[FormWriter](#formwriter) is an HTTP client connection adapter for writing HTML forms.

This class runs in its own thread so as not to block the event loop while uploading big files. Class members are not synchronized hence they should not be accessed while the form is sending, not that there would be any reason to do so.

## List of all members

| Name | Kind | Owner |
|------|------|-------|
| [`FormPart`](#formpart-3) | `friend` | Declared here |
| [`FilePart`](#filepart-5) | `friend` | Declared here |
| [`StringPart`](#stringpart) | `friend` | Declared here |
| [`emitter`](#emitter-11) | `variable` | Declared here |
| [`~FormWriter`](#formwriter-1) | `function` | Declared here |
| [`addPart`](#addpart) | `function` | Declared here |
| [`start`](#start-24) | `function` | Declared here |
| [`stop`](#stop-14) | `function` | Declared here |
| [`complete`](#complete-2) | `function` | Declared here |
| [`cancelled`](#cancelled-4) | `function` | Declared here |
| [`prepareSubmit`](#preparesubmit) | `function` | Declared here |
| [`calculateMultipartContentLength`](#calculatemultipartcontentlength) | `function` | Declared here |
| [`writeUrl`](#writeurl) | `function` | Declared here |
| [`writeMultipartChunk`](#writemultipartchunk) | `function` | Declared here |
| [`writeAsync`](#writeasync) | `function` | Declared here |
| [`setEncoding`](#setencoding) | `function` | Declared here |
| [`encoding`](#encoding) | `function` | Declared here |
| [`setBoundary`](#setboundary) | `function` | Declared here |
| [`boundary`](#boundary) | `function` | Declared here |
| [`connection`](#connection-6) | `function` | Declared here |
| [`ENCODING_URL`](#encoding_url) | `variable` | Declared here |
| [`ENCODING_MULTIPART_FORM`](#encoding_multipart_form) | `variable` | Declared here |
| [`ENCODING_MULTIPART_RELATED`](#encoding_multipart_related) | `variable` | Declared here |
| [`create`](#create-9) | `function` | Declared here |
| [`_stream`](#_stream) | `variable` | Declared here |
| [`_runner`](#_runner-2) | `variable` | Declared here |
| [`_encoding`](#_encoding) | `variable` | Declared here |
| [`_boundary`](#_boundary) | `variable` | Declared here |
| [`_parts`](#_parts) | `variable` | Declared here |
| [`_filesLength`](#_fileslength) | `variable` | Declared here |
| [`_writeState`](#_writestate) | `variable` | Declared here |
| [`_initial`](#_initial) | `variable` | Declared here |
| [`_complete`](#_complete-1) | `variable` | Declared here |
| [`FormWriter`](#formwriter-2) | `function` | Declared here |
| [`FormWriter`](#formwriter-3) | `function` | Declared here |
| [`operator=`](#operator-202) | `function` | Declared here |
| [`FormWriter`](#formwriter-4) | `function` | Declared here |
| [`operator=`](#operator-203) | `function` | Declared here |
| [`writePartHeader`](#writepartheader) | `function` | Declared here |
| [`writeEnd`](#writeend) | `function` | Declared here |
| [`updateProgress`](#updateprogress) | `function` | Declared here |
| [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-1) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-2) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-3) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`~NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-4) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#operator-64) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#operator-65) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`operator[]`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#operator-66) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`set`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#set-1) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`add`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#add-4) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`add`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#add-5) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`get`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#get-7) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`get`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#get-8) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`has`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#has-2) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`find`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#find) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`begin`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#begin-5) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`end`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#end-2) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`empty`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#empty-2) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`size`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#size-5) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`erase`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#erase-1) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`clear`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#clear-3) | `function` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`Map`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#map-6) | `typedef` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`Iterator`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#iterator) | `typedef` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`ConstIterator`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#constiterator) | `typedef` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`_map`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#_map-2) | `variable` | Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) |
| [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-1) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`~PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-2) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-1) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-2) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-3) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-4) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-5) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`getEmitter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#getemitter) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`retention`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#retention-1) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`onStreamStateChange`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#onstreamstatechange-1) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`_emitter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#_emitter) | `variable` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-3) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#operator-72) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-4) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#operator-73) | `function` | Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter) |
| [`start`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#start-21) | `function` | Inherited from [`Startable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#startable) |
| [`stop`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#stop-12) | `function` | Inherited from [`Startable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#startable) |

## Inherited from [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-1) `inline` |  |
| `function` | [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-2) `inline` |  |
| `function` | [`NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-3) `inline` `noexcept` |  |
| `function` | [`~NVCollection`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection-4) `virtual` `inline` |  |
| `function` | [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#operator-64)  | Assigns the name-value pairs of another [NVCollection](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) to this one. |
| `function` | [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#operator-65) `noexcept` |  |
| `function` | [`operator[]`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#operator-66) `const` | Returns the value of the (first) name-value pair with the given name. |
| `function` | [`set`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#set-1)  | Sets the value of the (first) name-value pair with the given name. |
| `function` | [`add`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#add-4)  | Adds a new name-value pair with the given name and value. |
| `function` | [`add`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#add-5)  | Adds a new name-value pair using move semantics. |
| `function` | [`get`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#get-7) `const` | Returns the value of the first name-value pair with the given name. |
| `function` | [`get`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#get-8) `const` | Returns the value of the first name-value pair with the given name. If no value with the given name has been found, the defaultValue is returned. |
| `function` | [`has`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#has-2) `const` | Returns true if there is at least one name-value pair with the given name. |
| `function` | [`find`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#find) `const` | Returns an iterator pointing to the first name-value pair with the given name. |
| `function` | [`begin`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#begin-5) `const` | Returns an iterator pointing to the begin of the name-value pair collection. |
| `function` | [`end`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#end-2) `const` | Returns an iterator pointing to the end of the name-value pair collection. |
| `function` | [`empty`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#empty-2) `const` | Returns true iff the header does not have any content. |
| `function` | [`size`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#size-5) `const` | Returns the number of name-value pairs in the collection. |
| `function` | [`erase`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#erase-1)  | Removes all name-value pairs with the given name. |
| `function` | [`clear`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#clear-3)  | Removes all name-value pairs and their values. |
| `typedef` | [`Map`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#map-6)  |  |
| `typedef` | [`Iterator`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#iterator)  |  |
| `typedef` | [`ConstIterator`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#constiterator)  |  |
| `variable` | [`_map`](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#_map-2)  |  |

## Inherited from [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-1)  | Construct the adapter, binding it to the given packet signal. |
| `function` | [`~PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-2) `virtual` `inline` |  |
| `function` | [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-1) `virtual` | Emit a mutable raw buffer as a packet. |
| `function` | [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-2) `virtual` | Emit a read-only raw buffer as a packet (data is copied internally). |
| `function` | [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-3) `virtual` | Emit a string as a packet (data is copied internally). |
| `function` | [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-4) `virtual` | Emit a flag-only packet carrying no payload data. |
| `function` | [`emit`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#emit-5) `virtual` | Emit an existing packet directly onto the outgoing signal. |
| `function` | [`getEmitter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#getemitter)  | Returns a reference to the outgoing packet signal. |
| `function` | [`retention`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#retention-1) `virtual` `const` | Returns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph. |
| `function` | [`onStreamStateChange`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#onstreamstatechange-1) `virtual` `inline` | Called by the [PacketStream](https://auscaster.com/icey/docs/api-reference/icy-PacketStream.md#packetstream) to notify when the internal [Stream](https://auscaster.com/icey/docs/api-reference/icy-Stream.md#stream) state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios. |
| `variable` | [`_emitter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#_emitter)  |  |
| `function` | [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-3)  | NonCopyable and NonMovable. |
| `function` | [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#operator-72)  | Deleted assignment operator. |
| `function` | [`PacketStreamAdapter`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#packetstreamadapter-4)  | Deleted constructor. |
| `function` | [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-PacketStreamAdapter.md#operator-73)  | Deleted assignment operator. |

## Inherited from [`Startable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#startable)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`start`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#start-21) `virtual` | Starts the object (e.g. begins processing or listening). |
| `function` | [`stop`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#stop-12) `virtual` | Stops the object (e.g. halts processing or closes resources). |

## Friends

| Name | Description |
|------|-------------|
| [`FormPart`](#formpart-3)  |  |
| [`FilePart`](#filepart-5)  |  |
| [`StringPart`](#stringpart)  |  |

---

<a id="formpart-3"></a>

### FormPart

```cpp
friend class FormPart
```

[Defined in src/http/include/icy/http/form.h:152](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L152)

---

<a id="filepart-5"></a>

### FilePart

```cpp
friend class FilePart
```

[Defined in src/http/include/icy/http/form.h:153](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L153)

---

<a id="stringpart"></a>

### StringPart

```cpp
friend class StringPart
```

[Defined in src/http/include/icy/http/form.h:154](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L154)

## Public Attributes

| Return | Name | Description |
|--------|------|-------------|
| [`PacketSignal`](https://auscaster.com/icey/docs/api-reference/base.md#packetsignal) | [`emitter`](#emitter-11)  | The outgoing packet emitter. |

---

<a id="emitter-11"></a>

### emitter

```cpp
PacketSignal emitter
```

Type: [`PacketSignal`](https://auscaster.com/icey/docs/api-reference/base.md#packetsignal)

[Defined in src/http/include/icy/http/form.h:122](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L122)

The outgoing packet emitter.

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`~FormWriter`](#formwriter-1) `virtual` | Destroys the [FormWriter](#formwriter). |
| `void` | [`addPart`](#addpart)  | Adds a part or file attachment to the multipart form. |
| `void` | [`start`](#start-24) `virtual` | Starts the sending thread. |
| `void` | [`stop`](#stop-14) `virtual` | Stops the sending thread. |
| `bool` | [`complete`](#complete-2) `const` | Returns true if the request is complete. |
| `bool` | [`cancelled`](#cancelled-4) `const` | Returns true if the request is cancelled. |
| `void` | [`prepareSubmit`](#preparesubmit)  | Prepares the outgoing HTTP request object for submitting the form. |
| `uint64_t` | [`calculateMultipartContentLength`](#calculatemultipartcontentlength)  | Processes the entire form body and computes its total byte length. Only meaningful for multipart/form-data when not using chunked encoding. |
| `void` | [`writeUrl`](#writeurl)  | Writes the complete "application/x-www-form-urlencoded" encoded body to `ostr`. All key-value pairs from the [NVCollection](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) base are percent-encoded and joined with '&'. |
| `void` | [`writeMultipartChunk`](#writemultipartchunk)  | Writes the next pending multipart chunk to the connection. Non-blocking; intended to be called repeatedly from the event loop until all parts have been sent. |
| `void` | [`writeAsync`](#writeasync)  | Writes the next message chunk from the background runner thread. Called by the [Runner](https://auscaster.com/icey/docs/api-reference/icy-Runner.md#runner); do not call directly. |
| `void` | [`setEncoding`](#setencoding)  | Sets the MIME encoding used for submitting the form. Must be set before [prepareSubmit()](#preparesubmit) is called. |
| `const std::string &` | [`encoding`](#encoding) `const` | Returns the encoding used for posting the form. |
| `void` | [`setBoundary`](#setboundary)  | Sets the MIME boundary string used to delimit multipart form parts. If not set, a random boundary is generated by [prepareSubmit()](#preparesubmit). Must be set before [prepareSubmit()](#preparesubmit) is called. |
| `const std::string &` | [`boundary`](#boundary) `const` | Returns the MIME boundary used for writing multipart form data. |
| [`ConnectionStream`](https://auscaster.com/icey/docs/api-reference/icy-http-ConnectionStream.md#connectionstream-1) & | [`connection`](#connection-6)  | The associated HTTP client connection. |

---

<a id="formwriter-1"></a>

### ~FormWriter

`virtual`

```cpp
virtual ~FormWriter()
```

[Defined in src/http/include/icy/http/form.h:57](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L57)

Destroys the [FormWriter](#formwriter).

---

<a id="addpart"></a>

### addPart

```cpp
void addPart(const std::string & name, FormPart * part)
```

[Defined in src/http/include/icy/http/form.h:65](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L65)

Adds a part or file attachment to the multipart form.

The [FormWriter](#formwriter) takes ownership of `part` and deletes it when done. Parts are only sent when the encoding is "multipart/form-data".

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | `const std::string &` | Form field name for this part. |
| `part` | [`FormPart`](https://auscaster.com/icey/docs/api-reference/icy-http-FormPart.md#formpart) * | [Part](https://auscaster.com/icey/docs/api-reference/icy-http-FormWriter-Part.md#part) to add. Ownership is transferred. |

---

<a id="start-24"></a>

### start

`virtual`

```cpp
virtual void start()
```

[Defined in src/http/include/icy/http/form.h:68](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L68)

Starts the sending thread.

#### Reimplements

- [`Startable::start`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#start-21)

---

<a id="stop-14"></a>

### stop

`virtual`

```cpp
virtual void stop()
```

[Defined in src/http/include/icy/http/form.h:71](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L71)

Stops the sending thread.

#### Reimplements

- [`Startable::stop`](https://auscaster.com/icey/docs/api-reference/icy-basic-Startable.md#stop-12)

---

<a id="complete-2"></a>

### complete

`const`

```cpp
bool complete() const
```

[Defined in src/http/include/icy/http/form.h:74](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L74)

Returns true if the request is complete.

---

<a id="cancelled-4"></a>

### cancelled

`const`

```cpp
bool cancelled() const
```

[Defined in src/http/include/icy/http/form.h:77](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L77)

Returns true if the request is cancelled.

---

<a id="preparesubmit"></a>

### prepareSubmit

```cpp
void prepareSubmit()
```

[Defined in src/http/include/icy/http/form.h:80](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L80)

Prepares the outgoing HTTP request object for submitting the form.

---

<a id="calculatemultipartcontentlength"></a>

### calculateMultipartContentLength

```cpp
uint64_t calculateMultipartContentLength()
```

[Defined in src/http/include/icy/http/form.h:85](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L85)

Processes the entire form body and computes its total byte length. Only meaningful for multipart/form-data when not using chunked encoding. 
#### Returns
Total content length in bytes.

---

<a id="writeurl"></a>

### writeUrl

```cpp
void writeUrl(std::ostream & ostr)
```

[Defined in src/http/include/icy/http/form.h:90](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L90)

Writes the complete "application/x-www-form-urlencoded" encoded body to `ostr`. All key-value pairs from the [NVCollection](https://auscaster.com/icey/docs/api-reference/icy-NVCollection.md#nvcollection) base are percent-encoded and joined with '&'.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `ostr` | `std::ostream &` | Output stream to write to. |

---

<a id="writemultipartchunk"></a>

### writeMultipartChunk

```cpp
void writeMultipartChunk()
```

[Defined in src/http/include/icy/http/form.h:95](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L95)

Writes the next pending multipart chunk to the connection. Non-blocking; intended to be called repeatedly from the event loop until all parts have been sent.

---

<a id="writeasync"></a>

### writeAsync

```cpp
void writeAsync()
```

[Defined in src/http/include/icy/http/form.h:99](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L99)

Writes the next message chunk from the background runner thread. Called by the [Runner](https://auscaster.com/icey/docs/api-reference/icy-Runner.md#runner); do not call directly.

---

<a id="setencoding"></a>

### setEncoding

```cpp
void setEncoding(const std::string & encoding)
```

[Defined in src/http/include/icy/http/form.h:104](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L104)

Sets the MIME encoding used for submitting the form. Must be set before [prepareSubmit()](#preparesubmit) is called.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `encoding` | `const std::string &` | MIME type: ENCODING_URL or ENCODING_MULTIPART_FORM. |

---

<a id="encoding"></a>

### encoding

`const`

```cpp
const std::string & encoding() const
```

[Defined in src/http/include/icy/http/form.h:107](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L107)

Returns the encoding used for posting the form.

---

<a id="setboundary"></a>

### setBoundary

```cpp
void setBoundary(const std::string & boundary)
```

[Defined in src/http/include/icy/http/form.h:113](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L113)

Sets the MIME boundary string used to delimit multipart form parts. If not set, a random boundary is generated by [prepareSubmit()](#preparesubmit). Must be set before [prepareSubmit()](#preparesubmit) is called.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `boundary` | `const std::string &` | Boundary string (without leading "--"). |

---

<a id="boundary"></a>

### boundary

`const`

```cpp
const std::string & boundary() const
```

[Defined in src/http/include/icy/http/form.h:116](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L116)

Returns the MIME boundary used for writing multipart form data.

---

<a id="connection-6"></a>

### connection

```cpp
ConnectionStream & connection()
```

[Defined in src/http/include/icy/http/form.h:119](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L119)

The associated HTTP client connection.

## Public Static Attributes

| Return | Name | Description |
|--------|------|-------------|
| `const char *` | [`ENCODING_URL`](#encoding_url) `static` | "application/x-www-form-urlencoded" |
| `const char *` | [`ENCODING_MULTIPART_FORM`](#encoding_multipart_form) `static` | "multipart/form-data" |
| `const char *` | [`ENCODING_MULTIPART_RELATED`](#encoding_multipart_related) `static` | "multipart/related" [http://tools.ietf.org/html/rfc2387](http://tools.ietf.org/html/rfc2387) |

---

<a id="encoding_url"></a>

### ENCODING_URL

`static`

```cpp
const char * ENCODING_URL
```

[Defined in src/http/include/icy/http/form.h:124](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L124)

"application/x-www-form-urlencoded"

---

<a id="encoding_multipart_form"></a>

### ENCODING_MULTIPART_FORM

`static`

```cpp
const char * ENCODING_MULTIPART_FORM
```

[Defined in src/http/include/icy/http/form.h:125](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L125)

"multipart/form-data"

---

<a id="encoding_multipart_related"></a>

### ENCODING_MULTIPART_RELATED

`static`

```cpp
const char * ENCODING_MULTIPART_RELATED
```

[Defined in src/http/include/icy/http/form.h:126](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L126)

"multipart/related" [http://tools.ietf.org/html/rfc2387](http://tools.ietf.org/html/rfc2387)

## Public Static Methods

| Return | Name | Description |
|--------|------|-------------|
| [`FormWriter`](#formwriter) * | [`create`](#create-9) `static` | Creates a [FormWriter](#formwriter) for the given connection and encoding. |

---

<a id="create-9"></a>

### create

`static`

```cpp
static FormWriter * create(ConnectionStream & conn, const std::string & encoding = FormWriter::ENCODING_URL)
```

[Defined in src/http/include/icy/http/form.h:54](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L54)

Creates a [FormWriter](#formwriter) for the given connection and encoding.

Encoding must be either "application/x-www-form-urlencoded" (which is the default) or "multipart/form-data". 
#### Returns
Heap-allocated [FormWriter](#formwriter). The caller owns the returned pointer.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `conn` | [`ConnectionStream`](https://auscaster.com/icey/docs/api-reference/icy-http-ConnectionStream.md#connectionstream-1) & | The HTTP connection stream to write form data to. |
| `encoding` | `const std::string &` | MIME encoding type. |

## Protected Attributes

| Return | Name | Description |
|--------|------|-------------|
| [`ConnectionStream`](https://auscaster.com/icey/docs/api-reference/icy-http-ConnectionStream.md#connectionstream-1) & | [`_stream`](#_stream)  |  |
| std::shared_ptr< [`Runner`](https://auscaster.com/icey/docs/api-reference/icy-Runner.md#runner) > | [`_runner`](#_runner-2)  |  |
| `std::string` | [`_encoding`](#_encoding)  |  |
| `std::string` | [`_boundary`](#_boundary)  |  |
| `PartQueue` | [`_parts`](#_parts)  |  |
| `uint64_t` | [`_filesLength`](#_fileslength)  |  |
| `int` | [`_writeState`](#_writestate)  |  |
| `bool` | [`_initial`](#_initial)  |  |
| `bool` | [`_complete`](#_complete-1)  |  |

---

<a id="_stream"></a>

### _stream

```cpp
ConnectionStream & _stream
```

Type: [`ConnectionStream`](https://auscaster.com/icey/docs/api-reference/icy-http-ConnectionStream.md#connectionstream-1) &

[Defined in src/http/include/icy/http/form.h:165](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L165)

---

<a id="_runner-2"></a>

### _runner

```cpp
std::shared_ptr< Runner > _runner
```

Type: std::shared_ptr< [`Runner`](https://auscaster.com/icey/docs/api-reference/icy-Runner.md#runner) >

[Defined in src/http/include/icy/http/form.h:166](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L166)

---

<a id="_encoding"></a>

### _encoding

```cpp
std::string _encoding
```

[Defined in src/http/include/icy/http/form.h:167](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L167)

---

<a id="_boundary"></a>

### _boundary

```cpp
std::string _boundary
```

[Defined in src/http/include/icy/http/form.h:168](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L168)

---

<a id="_parts"></a>

### _parts

```cpp
PartQueue _parts
```

Type: `PartQueue`

[Defined in src/http/include/icy/http/form.h:169](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L169)

---

<a id="_fileslength"></a>

### _filesLength

```cpp
uint64_t _filesLength
```

[Defined in src/http/include/icy/http/form.h:170](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L170)

---

<a id="_writestate"></a>

### _writeState

```cpp
int _writeState
```

[Defined in src/http/include/icy/http/form.h:171](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L171)

---

<a id="_initial"></a>

### _initial

```cpp
bool _initial
```

[Defined in src/http/include/icy/http/form.h:172](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L172)

---

<a id="_complete-1"></a>

### _complete

```cpp
bool _complete
```

[Defined in src/http/include/icy/http/form.h:173](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L173)

## Protected Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`FormWriter`](#formwriter-2)  | Creates the [FormWriter](#formwriter) that uses the given encoding. |
|  | [`FormWriter`](#formwriter-3)  | Deleted constructor. |
| [`FormWriter`](#formwriter) & | [`operator=`](#operator-202)  | Deleted assignment operator. |
|  | [`FormWriter`](#formwriter-4)  | Deleted constructor. |
| [`FormWriter`](#formwriter) & | [`operator=`](#operator-203)  | Deleted assignment operator. |
| `void` | [`writePartHeader`](#writepartheader)  | Writes the message boundary std::string, followed by the message header to the output stream. |
| `void` | [`writeEnd`](#writeend)  | Writes the final boundary std::string to the output stream. |
| `void` | [`updateProgress`](#updateprogress) `virtual` | Updates the upload progress via the associated [ConnectionStream](https://auscaster.com/icey/docs/api-reference/icy-http-ConnectionStream.md#connectionstream-1) object. |

---

<a id="formwriter-2"></a>

### FormWriter

```cpp
FormWriter(ConnectionStream & conn, std::shared_ptr< Runner > runner, const std::string & encoding = FormWriter::ENCODING_URL)
```

[Defined in src/http/include/icy/http/form.h:130](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L130)

Creates the [FormWriter](#formwriter) that uses the given encoding.

---

<a id="formwriter-3"></a>

### FormWriter

```cpp
FormWriter(const FormWriter &) = delete
```

[Defined in src/http/include/icy/http/form.h:133](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L133)

Deleted constructor.

---

<a id="operator-202"></a>

### operator=

```cpp
FormWriter & operator=(const FormWriter &) = delete
```

[Defined in src/http/include/icy/http/form.h:134](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L134)

Deleted assignment operator.

---

<a id="formwriter-4"></a>

### FormWriter

```cpp
FormWriter(FormWriter &&) = delete
```

[Defined in src/http/include/icy/http/form.h:135](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L135)

Deleted constructor.

---

<a id="operator-203"></a>

### operator=

```cpp
FormWriter & operator=(FormWriter &&) = delete
```

[Defined in src/http/include/icy/http/form.h:136](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L136)

Deleted assignment operator.

---

<a id="writepartheader"></a>

### writePartHeader

```cpp
void writePartHeader(const NVCollection & header, std::ostream & ostr)
```

[Defined in src/http/include/icy/http/form.h:140](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L140)

Writes the message boundary std::string, followed by the message header to the output stream.

---

<a id="writeend"></a>

### writeEnd

```cpp
void writeEnd(std::ostream & ostr)
```

[Defined in src/http/include/icy/http/form.h:143](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L143)

Writes the final boundary std::string to the output stream.

---

<a id="updateprogress"></a>

### updateProgress

`virtual`

```cpp
virtual void updateProgress(int nread)
```

[Defined in src/http/include/icy/http/form.h:150](https://github.com/auscaster/icey/blob/main/src/http/include/icy/http/form.h#L150)

Updates the upload progress via the associated [ConnectionStream](https://auscaster.com/icey/docs/api-reference/icy-http-ConnectionStream.md#connectionstream-1) object.
