Commit ddc312bf authored by hydratim's avatar hydratim

Still attempting to fix "Invalid port" error

Can't get tests to run locally for some reason
parent 18fd919d
......@@ -6,6 +6,7 @@
#include <stdexcept>
#include <iterator>
#include <limits>
#include <cstring>
#include <iostream>
......@@ -361,15 +362,14 @@ Host::parse(const std::string& data) {
char *end;
const std::string portPart = data.substr(pos + 1);
long port;
if (portPart.empty()) {
port = HTTP_STANDARD_PORT;
}
else {
if (pos != std::string::npos) {
port = strtol(portPart.c_str(), &end, 10);
if (port < std::numeric_limits<uint16_t>::min()|| port > std::numeric_limits<uint16_t>::max())
throw std::invalid_argument("Invalid port");
port_ = static_cast<uint16_t>(port);
} else {
port_ = HTTP_STANDARD_PORT;
}
if (*end != 0 || port < Port::min() || port > Port::max())
throw std::invalid_argument("Invalid port");
port_ = static_cast<uint16_t>(port);
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment