summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-24 12:59:17 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-24 12:59:17 +0000
commit2df82171637c28184c2f585ae49efb5bcf588859 (patch)
tree3d52e6250591ca74738979a2d4349c1e07bf9762
parent305385e06f90ca3216e1aa4e43b20dd7d53c1222 (diff)
downloadtipidee-2df82171637c28184c2f585ae49efb5bcf588859.tar.xz
support Host as HTTP/1.05
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/tipideed/tipideed.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c
index cf961db..aef608b 100644
--- a/src/tipideed/tipideed.c
+++ b/src/tipideed/tipideed.c
@@ -511,23 +511,23 @@ int main (int argc, char const *const *argv, char const *const *envp)
default : strerr_dief2x(101, "can't happen: ", "unknown HTTP method") ;
}
- if (rql.http_minor)
+ x = tipidee_headers_search(&hdr, "Host") ; /* HTTP/1.05 */
+ if (x)
{
- x = tipidee_headers_search(&hdr, "Host") ;
- if (x)
+ char *p = strchr(x, ':') ;
+ if (p)
{
- char *p = strchr(x, ':') ;
- if (p)
- {
- if (!uint160_scan(p+1, &rql.uri.port)) eexit_400(&rql, "Invalid Host header") ;
- *p = 0 ;
- }
- if (!*x || *x == '.') eexit_400(&rql, "Invalid Host header") ;
- rql.uri.host = x ;
+ if (!uint160_scan(p+1, &rql.uri.port)) eexit_400(&rql, "Invalid Host header") ;
+ *p = 0 ;
}
- else if (!rql.uri.host) eexit_400(&rql, "Missing Host header") ;
+ if (!*x || *x == '.') eexit_400(&rql, "Invalid Host header") ;
+ rql.uri.host = x ;
+ }
+ else if (!rql.uri.host)
+ {
+ if (rql.http_minor) eexit_400(&rql, "Missing Host header") ;
+ else rql.uri.host = g.defaulthost ;
}
- else if (!rql.uri.host) rql.uri.host = g.defaulthost ;
if (!rql.uri.port) rql.uri.port = g.defaultport ;
tipidee_log_request(g.logv, &rql, &hdr, &g.sa) ;