From 159dd0d06f20c17e609e2a02c6aaafb3a3e6d0d9 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 7 Oct 2023 12:26:10 +0200 Subject: [PATCH] http::do: handle more protoerror cases --- net/http/do.ha | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/net/http/do.ha b/net/http/do.ha index 4631c71..a9b2c16 100644 --- a/net/http/do.ha +++ b/net/http/do.ha @@ -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); };