1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.http: support -d trace_http_request and -d trace_http_response

This commit is contained in:
Delyan Angelov
2021-03-30 18:11:00 +03:00
parent 205fb88d90
commit 683eaad66f
3 changed files with 36 additions and 14 deletions

View File

@@ -37,6 +37,9 @@ fn (req &Request) ssl_do(port int, method Method, host_name string, path string)
res = C.SSL_get_verify_result(voidptr(ssl))
// /////
req_headers := req.build_request_headers(method, host_name, path)
$if trace_http_request ? {
eprintln('> $req_headers')
}
// println(req_headers)
C.BIO_puts(web, req_headers.str)
mut content := strings.new_builder(100)
@@ -63,5 +66,9 @@ fn (req &Request) ssl_do(port int, method Method, host_name string, path string)
if ctx != 0 {
C.SSL_CTX_free(ctx)
}
return parse_response(content.str())
response_text := content.str()
$if trace_http_response ? {
eprintln('< $response_text')
}
return parse_response(response_text)
}