| 235 | } |
| 236 | |
| 237 | size_t HttpMultipartWriter::getContentLength() const |
| 238 | { |
| 239 | size_t total = 0; |
| 240 | for (size_t idx = 0; idx < numParts; ++idx) |
| 241 | { |
| 242 | const Part& part = parts[idx]; |
| 243 | total += 2 + boundary.sizeInBytes() + 2; // --boundary\r\n |
| 244 | total += sizeof("Content-Disposition: form-data; name=\"") - 1; |
| 245 | total += part.partName.sizeInBytes(); |
| 246 | total += 1; |
| 247 | if (part.fileName.sizeInBytes() > 0) |
| 248 | { |
| 249 | total += sizeof("; filename=\"") - 1; |
| 250 | total += part.fileName.sizeInBytes(); |
| 251 | total += 1; |
| 252 | } |
| 253 | total += 2; |
| 254 | |
| 255 | if (part.contentType.sizeInBytes() > 0) |
| 256 | { |
| 257 | total += sizeof("Content-Type: ") - 1; |
| 258 | total += part.contentType.sizeInBytes(); |
| 259 | total += 2; |
| 260 | } |
| 261 | total += 2; |
| 262 | total += part.body.sizeInBytes(); |
| 263 | total += 2; |
| 264 | } |
| 265 | total += 2 + boundary.sizeInBytes() + 4; // --boundary--\r\n |
| 266 | return total; |
| 267 | } |
| 268 | //------------------------------------------------------------------------------------------------------- |
| 269 | // HttpConnection |
| 270 | //------------------------------------------------------------------------------------------------------- |