committed by
Sacha Al Himdani
parent
3c7a27b7ff
commit
b1cc17ab26
@@ -170,6 +170,7 @@ func TestTrustCenter_LogoFileDownloadURL(t *testing.T) {
|
||||
// redirect) with cache headers, so the stable URL is CDN/browser cacheable.
|
||||
resp, err := http.Get(downloadURL)
|
||||
require.NoError(t, err)
|
||||
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
@@ -199,6 +200,7 @@ func TestTrustCenter_LogoFileDownloadURL(t *testing.T) {
|
||||
|
||||
revalidateResp, err := http.DefaultClient.Do(revalidateReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
defer func() { _ = revalidateResp.Body.Close() }()
|
||||
|
||||
assert.Equal(t, http.StatusNotModified, revalidateResp.StatusCode)
|
||||
@@ -214,6 +216,7 @@ func TestTrustCenter_LogoFileDownloadURL(t *testing.T) {
|
||||
|
||||
sinceResp, err := http.DefaultClient.Do(sinceReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
defer func() { _ = sinceResp.Body.Close() }()
|
||||
|
||||
assert.Equal(t, http.StatusNotModified, sinceResp.StatusCode)
|
||||
|
||||
@@ -30,9 +30,6 @@ import (
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
)
|
||||
|
||||
// FileObject carries a streamed S3 object body plus the metadata needed to set
|
||||
// HTTP response headers. NotModified is set when the caller's conditional
|
||||
// request matched the current object, in which case Body is nil.
|
||||
type FileObject struct {
|
||||
Body io.ReadCloser
|
||||
ContentType string
|
||||
@@ -42,9 +39,6 @@ type FileObject struct {
|
||||
NotModified bool
|
||||
}
|
||||
|
||||
// FileConditions carries HTTP conditional-request values forwarded to S3 so it
|
||||
// can answer with 304 Not Modified without transferring the body. Zero values
|
||||
// are omitted.
|
||||
type FileConditions struct {
|
||||
IfNoneMatch string
|
||||
IfModifiedSince time.Time
|
||||
@@ -100,10 +94,6 @@ func (s *Service) GetFileBytes(
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// OpenFile streams an object from S3 without buffering it in memory. Conditional
|
||||
// request values in conds are forwarded to S3; a 304 Not Modified response is
|
||||
// surfaced as a FileObject with NotModified set (and a nil Body). The caller
|
||||
// owns closing Body.
|
||||
func (s *Service) OpenFile(
|
||||
ctx context.Context,
|
||||
file *coredata.File,
|
||||
@@ -116,6 +106,7 @@ func (s *Service) OpenFile(
|
||||
if conds.IfNoneMatch != "" {
|
||||
input.IfNoneMatch = &conds.IfNoneMatch
|
||||
}
|
||||
|
||||
if !conds.IfModifiedSince.IsZero() {
|
||||
input.IfModifiedSince = &conds.IfModifiedSince
|
||||
}
|
||||
@@ -140,6 +131,7 @@ func (s *Service) OpenFile(
|
||||
if result.ETag != nil {
|
||||
obj.ETag = *result.ETag
|
||||
}
|
||||
|
||||
if result.LastModified != nil {
|
||||
obj.LastModified = *result.LastModified
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user