| 1429 | } |
| 1430 | |
| 1431 | int64_t HttpIo::HttpImpl::getFileLength() { |
| 1432 | Exiv2::Dictionary response; |
| 1433 | Exiv2::Dictionary request; |
| 1434 | std::string errors; |
| 1435 | request["server"] = hostInfo_.Host; |
| 1436 | request["page"] = hostInfo_.Path; |
| 1437 | if (!hostInfo_.Port.empty()) |
| 1438 | request["port"] = hostInfo_.Port; |
| 1439 | request["verb"] = "HEAD"; |
| 1440 | int serverCode = http(request, response, errors); |
| 1441 | if (serverCode < 0 || serverCode >= 400 || !errors.empty()) { |
| 1442 | throw Error(ErrorCode::kerFileOpenFailed, "http", serverCode, hostInfo_.Path); |
| 1443 | } |
| 1444 | |
| 1445 | auto lengthIter = response.find("Content-Length"); |
| 1446 | return (lengthIter == response.end()) ? -1 : atol((lengthIter->second).c_str()); |
| 1447 | } |
| 1448 | |
| 1449 | void HttpIo::HttpImpl::getDataByRange(size_t lowBlock, size_t highBlock, std::string& response) { |
| 1450 | Exiv2::Dictionary responseDic; |