Closed travisbrady closed 4 years ago
@travisbrady http_request_method(...)
returns a struct http_string_s
. In the documentation it says that .buf
is not \0
-terminated
https://github.com/jeremycw/httpserver.h/blob/79ff2d8c20a997f55d7c7f4a2e91f1d55060efa3/httpserver.h#L92-L97
It is simply a pointer into the whole request. When printing it you should only print up to .len
chars.
Yes, @ioppermann is correct. You can print it by passing the length to printf along with the correct format string:
printf("test %.*s\n", str.len, str.buf);
When I add a call to
http_request_method
to the simple example in the readme it seems to return the entire request, as opposed to just the method.Example code:
Compile and execute:
After hitting in my browser it prints the following to the terminal: