| 267 | } |
| 268 | |
| 269 | bool http_mime::save_param(ostream &out, const std::string& bound, |
| 270 | const std::pair<std::string, std::string>& param) { |
| 271 | string buf; |
| 272 | buf.copy(bound.c_str(), bound.size()); |
| 273 | buf.append("\r\n"); |
| 274 | |
| 275 | const char disposition[] = "Content-Disposition: form-data; name=\""; |
| 276 | buf.append(disposition, sizeof(disposition) - 1); |
| 277 | if (!param.first.empty()) { |
| 278 | buf.append(param.first.c_str(), param.first.size()); |
| 279 | } |
| 280 | buf.append("\"\r\n\r\n"); |
| 281 | |
| 282 | if (!param.second.empty()) { |
| 283 | buf.append(param.second.c_str(), param.second.size()); |
| 284 | } |
| 285 | buf.append("\r\n"); |
| 286 | |
| 287 | if (out.write(buf) == false) { |
| 288 | logger_error("write to file error: %s", last_serror()); |
| 289 | return false; |
| 290 | } |
| 291 | return true; |
| 292 | } |
| 293 | |
| 294 | bool http_mime::save_file(ostream &out, const std::string& bound, |
| 295 | const std::pair<std::string, pair_value>& file) { |