1
Fork 0

http::do: handle more protoerror cases

This commit is contained in:
Drew DeVault 2023-10-07 12:26:10 +02:00
parent dbeb079262
commit 159dd0d06f

View file

@ -100,15 +100,31 @@ fn read_statusline(
const (_, version) = strings::cut(version, "/");
const (major, minor) = strings::cut(version, ".");
resp.version = (
strconv::stou(major)!,
strconv::stou(minor)!,
);
const major = match (strconv::stou(major)) {
case let u: uint =>
yield u;
case =>
return protoerr;
};
const minor = match (strconv::stou(minor)) {
case let u: uint =>
yield u;
case =>
return protoerr;
};
resp.version = (major, minor);
if (resp.version.0 > 1) {
return errors::unsupported;
};
resp.status = strconv::stou(status)!;
resp.status = match (strconv::stou(status)) {
case let u: uint =>
yield u;
case =>
return protoerr;
};
resp.reason = strings::dup(reason);
};