From 210b6e36b6e1584c1078e858ea540aa731a3e97c Mon Sep 17 00:00:00 2001 From: jm-duro <64472859+jm-duro@users.noreply.github.com> Date: Tue, 28 Apr 2020 13:57:48 +0200 Subject: [PATCH] http: mutable request fields --- examples/fetch.v | 13 +++++++++++++ vlib/net/http/http.v | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 examples/fetch.v diff --git a/examples/fetch.v b/examples/fetch.v new file mode 100644 index 0000000000..7f2b8626e7 --- /dev/null +++ b/examples/fetch.v @@ -0,0 +1,13 @@ +import time +import net.http + +fn main() { + resp := http.get('https://vlang.io/utc_now') or { + println('failed to fetch data from the server') + return + } + + t := time.unix(resp.text.int()) + println(t.format()) +} + diff --git a/vlib/net/http/http.v b/vlib/net/http/http.v index e1951993d7..e9f658b7fd 100644 --- a/vlib/net/http/http.v +++ b/vlib/net/http/http.v @@ -12,7 +12,7 @@ const ( ) pub struct Request { -pub: +pub mut: method string headers map[string]string cookies map[string]string