* This type defines a HTTP request structure. * This structure is used to send HTTP requests to the worker task. * * Attention, constructor and destructor of the members are not called! */
| 85 | * Attention, constructor and destructor of the members are not called! |
| 86 | */ |
| 87 | struct WorkerRequest |
| 88 | { |
| 89 | HttpJobId jobId; /**< Job id of the HTTP request/response. */ |
| 90 | String url; /**< URL of the HTTP request. */ |
| 91 | HttpMethod method; /**< HTTP method of the request. */ |
| 92 | const uint8_t* payload; /**< Payload of the HTTP request (only for POST). */ |
| 93 | size_t size; /**< Size of the payload in byte (only for POST). */ |
| 94 | IHttpResponseHandler* handler; /**< Optional response handler which will be called when the response is available. */ |
| 95 | |
| 96 | /** |
| 97 | * Constructs the HTTP request. |
| 98 | */ |
| 99 | WorkerRequest() : |
| 100 | jobId(INVALID_HTTP_JOB_ID), |
| 101 | url(), |
| 102 | method(HTTP_METHOD_GET), |
| 103 | payload(nullptr), |
| 104 | size(0U), |
| 105 | handler(nullptr) |
| 106 | { |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Copy constructor. |
| 111 | * |
| 112 | * @param[in] other Other HTTP request to copy. |
| 113 | */ |
| 114 | WorkerRequest(const WorkerRequest& other) : |
| 115 | jobId(other.jobId), |
| 116 | url(other.url), |
| 117 | method(other.method), |
| 118 | payload(nullptr), |
| 119 | size(other.size), |
| 120 | handler(other.handler) |
| 121 | { |
| 122 | if (nullptr != other.payload) |
| 123 | { |
| 124 | uint8_t* buffer = new (std::nothrow) uint8_t[size]; |
| 125 | |
| 126 | if (nullptr == buffer) |
| 127 | { |
| 128 | size = 0U; |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | memcpy(buffer, other.payload, size); |
| 133 | payload = buffer; |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Move constructor. |
| 140 | * |
| 141 | * @param[in] other Other HTTP request to move from. |
| 142 | */ |
| 143 | WorkerRequest(WorkerRequest&& other) noexcept : |
| 144 | jobId(other.jobId), |