-# $OpenBSD: Makefile,v 1.10 2023/06/13 11:41:36 claudio Exp $
+# $OpenBSD: Makefile,v 1.11 2024/03/12 16:03:56 job Exp $
PROGS += test-http
./test-http https://${SERVER}/HTTP/TE/foo.txt foo.txt
./test-http https://${SERVER}/HTTP/ChunkedScript chunk.out
./test-http https://${SERVER}/HTTP/300/307.html redir.out
+ -./test-http https://tinyurl.com/bd27n56t /dev/zero
sha256 -c ${.CURDIR}/test-http.sum
.else
# server ${SERVER} not reachable
return (ts.tv_sec);
}
+int
+valid_origin(const char *uri, const char *proto)
+{
+ const char *to;
+
+ /* extract end of host from proto URI */
+ to = strstr(proto, "://");
+ if (to == NULL)
+ return 0;
+ to += strlen("://");
+ if ((to = strchr(to, '/')) == NULL)
+ return 0;
+
+ /* compare hosts including the / for the start of the path section */
+ if (strncasecmp(uri, proto, to - proto + 1) != 0)
+ return 0;
+
+ return 1;
+}
+
static void
http_request(unsigned int id, const char *uri, const char *last_mod, int fd)
{