fix: propagate AllowHTTP to SourceURL() scheme selection
SourceURL() previously hardcoded https:// regardless of the AllowHTTP config setting. This made testing with HTTP-only test servers impossible. Add AllowHTTP field to ImageRequest and use it to determine the URL scheme. The Service propagates the config setting to each request. Fixes #1
This commit is contained in:
@@ -79,11 +79,18 @@ type ImageRequest struct {
|
||||
Signature string
|
||||
// Expires is the signature expiration timestamp
|
||||
Expires time.Time
|
||||
// AllowHTTP indicates whether HTTP (non-TLS) is allowed for this request
|
||||
AllowHTTP bool
|
||||
}
|
||||
|
||||
// SourceURL returns the full upstream URL to fetch
|
||||
// SourceURL returns the full upstream URL to fetch.
|
||||
// Uses http:// scheme when AllowHTTP is true, otherwise https://.
|
||||
func (r *ImageRequest) SourceURL() string {
|
||||
url := "https://" + r.SourceHost + r.SourcePath
|
||||
scheme := "https"
|
||||
if r.AllowHTTP {
|
||||
scheme = "http"
|
||||
}
|
||||
url := scheme + "://" + r.SourceHost + r.SourcePath
|
||||
if r.SourceQuery != "" {
|
||||
url += "?" + r.SourceQuery
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user