| 213 | } |
| 214 | |
| 215 | void parseMultipartFields(const String &body, const String &contentType, WebParamMap ¶ms) { |
| 216 | String boundary = multipartBoundary(contentType); |
| 217 | if (boundary.isEmpty()) return; |
| 218 | int pos = 0; |
| 219 | while (true) { |
| 220 | int partStart = body.indexOf(boundary, pos); |
| 221 | if (partStart < 0) break; |
| 222 | partStart += boundary.length(); |
| 223 | if (body.substring(partStart, partStart + 2) == "--") break; |
| 224 | if (body.substring(partStart, partStart + 2) == "\r\n") partStart += 2; |
| 225 | int headerEnd = body.indexOf("\r\n\r\n", partStart); |
| 226 | if (headerEnd < 0) break; |
| 227 | String headers = body.substring(partStart, headerEnd); |
| 228 | String name = extractDispositionValue(headers, "name"); |
| 229 | String filename = extractDispositionValue(headers, "filename"); |
| 230 | int dataStart = headerEnd + 4; |
| 231 | int next = body.indexOf("\r\n" + boundary, dataStart); |
| 232 | if (next < 0) break; |
| 233 | if (!name.isEmpty() && filename.isEmpty()) params.values[name] = body.substring(dataStart, next); |
| 234 | pos = next + 2; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | WebParamMap readParams(httpd_req_t *req) { |
| 239 | WebParamMap params; |
no test coverage detected