From cb8e2a5ae27aa34f2a9ad21469538403274e3b3e Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Thu, 4 Jul 2024 15:27:10 +0200 Subject: Discovery: Implement conditional requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From docs.eduvpn.org (https://docs.eduvpn.org/server/v3/server-discovery.html): When fetching the new JSON files, the client SHOULD use conditional requests, so the file is only fetched in case there were changes. This, in order to reduce the amount of traffic required by VPN clients, especially relevant for metered, or slow connections. The If-Modified-Since request header SHOULD be used for this. If the response code is 304, the file hasn’t changed since. The value to use for the If-Modified-Since request header is the exact value of the Last-Modified response header for the last successful download, i.e. 200 response. You SHOULD store the value of Last-Modified and use it as-is for the If-Modified-Since header. --- internal/http/http.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'internal/http') diff --git a/internal/http/http.go b/internal/http/http.go index 09f1953..196998b 100644 --- a/internal/http/http.go +++ b/internal/http/http.go @@ -164,11 +164,6 @@ func (c *Client) Get(ctx context.Context, url string) (http.Header, []byte, erro return c.Do(ctx, http.MethodGet, url, nil) } -// PostWithOpts creates a Post request with optional parameters and returns the headers, body and an error. -func (c *Client) PostWithOpts(ctx context.Context, url string, opts *OptionalParams) (http.Header, []byte, error) { - return c.Do(ctx, http.MethodPost, url, opts) -} - // Do sends a HTTP request using a method (e.g. GET, POST), an url and optional parameters // It returns the HTTP headers, the body and an error if there is one. func (c *Client) Do(ctx context.Context, method string, urlStr string, opts *OptionalParams) (http.Header, []byte, error) { -- cgit v1.2.3