| 203 | |
| 204 | |
| 205 | void HTMLForm::prepareSubmit(HTTPRequest& request, int options) |
| 206 | { |
| 207 | if (request.getMethod() == HTTPRequest::HTTP_POST || request.getMethod() == HTTPRequest::HTTP_PUT) |
| 208 | { |
| 209 | if (_encoding == ENCODING_URL) |
| 210 | { |
| 211 | request.setContentType(_encoding); |
| 212 | request.setChunkedTransferEncoding(false); |
| 213 | Poco::CountingOutputStream ostr; |
| 214 | writeUrl(ostr); |
| 215 | request.setContentLength(ostr.chars()); |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | _boundary = MultipartWriter::createBoundary(); |
| 220 | std::string ct(_encoding); |
| 221 | ct.append("; boundary=\""); |
| 222 | ct.append(_boundary); |
| 223 | ct.append("\""); |
| 224 | request.setContentType(ct); |
| 225 | } |
| 226 | if (request.getVersion() == HTTPMessage::HTTP_1_0) |
| 227 | { |
| 228 | request.setKeepAlive(false); |
| 229 | request.setChunkedTransferEncoding(false); |
| 230 | } |
| 231 | else if (_encoding != ENCODING_URL && (options & OPT_USE_CONTENT_LENGTH) == 0) |
| 232 | { |
| 233 | request.setChunkedTransferEncoding(true); |
| 234 | } |
| 235 | if (!request.getChunkedTransferEncoding() && !request.hasContentLength()) |
| 236 | { |
| 237 | request.setContentLength(calculateContentLength()); |
| 238 | } |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | std::string uri = request.getURI(); |
| 243 | std::ostringstream ostr; |
| 244 | writeUrl(ostr); |
| 245 | uri.append("?"); |
| 246 | uri.append(ostr.str()); |
| 247 | request.setURI(uri); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | |
| 252 | std::streamsize HTMLForm::calculateContentLength() |
nothing calls this directly
no test coverage detected