darkweak / go-esi

Pure implementation of the non-standard ESI (Edge-Side-Include) specification in Go
MIT License
22 stars 6 forks source link

feat: pass some headers to child requests #9

Closed dkarlovi closed 1 year ago

dkarlovi commented 1 year ago

Closes #5.

dkarlovi commented 1 year ago

@dunglas would appreciate your feedback too.

darkweak commented 1 year ago

https://github.com/darkweak/go-esi/pull/9/files#diff-49119e92a6bdccc63d27f7f553246cf3297eb16dc4a8cc08fa2ab344351facacR91 Apply these changes below:

    if (err != nil || response.StatusCode >= 400) && i.alt != "" {
        rq, _ = http.NewRequest(http.MethodGet, sanitizeURL(i.alt, req.URL), nil)
        addHeaders(headersSafe, req, rq)
        if rq.URL.Scheme == req.URL.Scheme && rq.URL.Host == req.URL.Host {
            addHeaders(headersUnsafe, req, rq)
        }
        response, err = client.Do(rq)

        if err != nil || response.StatusCode >= 400 {
            return nil, len(b)
        }
    }

    if response == nil {
        return nil, i.length
    }
dkarlovi commented 1 year ago

Closing here so not to cause conflicts in #10, see https://github.com/darkweak/go-esi/pull/10#issuecomment-1324777361