imagefetcher -> fetcher

This commit is contained in:
Viktor Sokolov
2025-09-05 00:38:25 +02:00
parent caffdcd72b
commit e09ba6d529
10 changed files with 29 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
package imagefetcher
package fetcher
import (
"errors"

View File

@@ -1,4 +1,4 @@
package imagefetcher
package fetcher
import (
"context"

View File

@@ -1,6 +1,6 @@
// imagefetcher is responsible for downloading images using HTTP requests through various protocols
// fetcher is responsible for downloading images using HTTP requests through various protocols
// defined in transport package
package imagefetcher
package fetcher
import (
"context"

View File

@@ -1,4 +1,4 @@
package imagefetcher
package fetcher
import (
"compress/gzip"

View File

@@ -5,9 +5,9 @@ import (
"errors"
"net/http"
"github.com/imgproxy/imgproxy/v3/fetcher"
"github.com/imgproxy/imgproxy/v3/headerwriter"
"github.com/imgproxy/imgproxy/v3/ierrors"
"github.com/imgproxy/imgproxy/v3/imagefetcher"
"github.com/imgproxy/imgproxy/v3/imagetype"
"github.com/imgproxy/imgproxy/v3/monitoring"
"github.com/imgproxy/imgproxy/v3/monitoring/stats"
@@ -81,7 +81,7 @@ func (r *request) execute(ctx context.Context) error {
}
// Respond with NotModified if image was not modified
var nmErr imagefetcher.NotModifiedError
var nmErr fetcher.NotModifiedError
if errors.As(err, &nmErr) {
r.hwr.SetOriginHeaders(nmErr.Headers())

View File

@@ -7,10 +7,10 @@ import (
"sync"
"github.com/imgproxy/imgproxy/v3/cookies"
"github.com/imgproxy/imgproxy/v3/fetcher"
"github.com/imgproxy/imgproxy/v3/headerwriter"
"github.com/imgproxy/imgproxy/v3/httpheaders"
"github.com/imgproxy/imgproxy/v3/ierrors"
"github.com/imgproxy/imgproxy/v3/imagefetcher"
"github.com/imgproxy/imgproxy/v3/monitoring"
"github.com/imgproxy/imgproxy/v3/monitoring/stats"
"github.com/imgproxy/imgproxy/v3/options"
@@ -35,9 +35,9 @@ var (
// Handler handles image passthrough requests, allowing images to be streamed directly
type Handler struct {
config *Config // Configuration for the streamer
fetcher *imagefetcher.Fetcher // Fetcher instance to handle image fetching
hw *headerwriter.Writer // Configured HeaderWriter instance
config *Config // Configuration for the streamer
fetcher *fetcher.Fetcher // Fetcher instance to handle image fetching
hw *headerwriter.Writer // Configured HeaderWriter instance
}
// request holds the parameters and state for a single streaming request
@@ -52,7 +52,7 @@ type request struct {
}
// New creates new handler object
func New(config *Config, hw *headerwriter.Writer, fetcher *imagefetcher.Fetcher) (*Handler, error) {
func New(config *Config, hw *headerwriter.Writer, fetcher *fetcher.Fetcher) (*Handler, error) {
if err := config.Validate(); err != nil {
return nil, err
}

View File

@@ -16,9 +16,9 @@ import (
"github.com/stretchr/testify/suite"
"github.com/imgproxy/imgproxy/v3/config"
"github.com/imgproxy/imgproxy/v3/fetcher"
"github.com/imgproxy/imgproxy/v3/headerwriter"
"github.com/imgproxy/imgproxy/v3/httpheaders"
"github.com/imgproxy/imgproxy/v3/imagefetcher"
"github.com/imgproxy/imgproxy/v3/options"
"github.com/imgproxy/imgproxy/v3/transport"
)
@@ -55,9 +55,9 @@ func (s *HandlerTestSuite) SetupTest() {
tr, err := transport.New(trc)
s.Require().NoError(err)
fc := imagefetcher.NewDefaultConfig()
fc := fetcher.NewDefaultConfig()
fetcher, err := imagefetcher.NewFetcher(tr, fc)
fetcher, err := fetcher.NewFetcher(tr, fc)
s.Require().NoError(err)
cfg := NewDefaultConfig()
@@ -356,9 +356,9 @@ func (s *HandlerTestSuite) TestHandlerCacheControl() {
tr, err := transport.New(trc)
s.Require().NoError(err)
fc := imagefetcher.NewDefaultConfig()
fc := fetcher.NewDefaultConfig()
fetcher, err := imagefetcher.NewFetcher(tr, fc)
fetcher, err := fetcher.NewFetcher(tr, fc)
s.Require().NoError(err)
cfg := NewDefaultConfig()
@@ -453,8 +453,8 @@ func (s *HandlerTestSuite) TestHandlerCookiePassthrough() {
tr, err := transport.New(trc)
s.Require().NoError(err)
fc := imagefetcher.NewDefaultConfig()
fetcher, err := imagefetcher.NewFetcher(tr, fc)
fc := fetcher.NewDefaultConfig()
fetcher, err := fetcher.NewFetcher(tr, fc)
s.Require().NoError(err)
cfg := NewDefaultConfig()
@@ -513,8 +513,8 @@ func (s *HandlerTestSuite) TestHandlerCanonicalHeader() {
tr, err := transport.New(trc)
s.Require().NoError(err)
fc := imagefetcher.NewDefaultConfig()
fetcher, err := imagefetcher.NewFetcher(tr, fc)
fc := fetcher.NewDefaultConfig()
fetcher, err := fetcher.NewFetcher(tr, fc)
s.Require().NoError(err)
cfg := NewDefaultConfig()

View File

@@ -5,13 +5,13 @@ import (
"net/http"
"github.com/imgproxy/imgproxy/v3/config"
"github.com/imgproxy/imgproxy/v3/fetcher"
"github.com/imgproxy/imgproxy/v3/ierrors"
"github.com/imgproxy/imgproxy/v3/imagefetcher"
"github.com/imgproxy/imgproxy/v3/transport"
)
var (
Fetcher *imagefetcher.Fetcher
Fetcher *fetcher.Fetcher
// For tests. This needs to move to fetcher once we will have a way to isolate
// the fetcher in tests.
@@ -45,12 +45,12 @@ func initDownloading() error {
return err
}
c, err := imagefetcher.LoadFromEnv(imagefetcher.NewDefaultConfig())
c, err := fetcher.LoadFromEnv(fetcher.NewDefaultConfig())
if err != nil {
return ierrors.Wrap(err, 0, ierrors.WithPrefix("configuration error"))
}
Fetcher, err = imagefetcher.NewFetcher(ts, c)
Fetcher, err = fetcher.NewFetcher(ts, c)
if err != nil {
return ierrors.Wrap(err, 0, ierrors.WithPrefix("can't create image fetcher"))
}

View File

@@ -3,13 +3,13 @@ package imagedata
import (
"fmt"
"github.com/imgproxy/imgproxy/v3/fetcher"
"github.com/imgproxy/imgproxy/v3/ierrors"
"github.com/imgproxy/imgproxy/v3/imagefetcher"
)
func wrapDownloadError(err error, desc string) error {
return ierrors.Wrap(
imagefetcher.WrapError(err), 0,
fetcher.WrapError(err), 0,
ierrors.WithPrefix(fmt.Sprintf("can't download %s", desc)),
)
}

View File

@@ -9,7 +9,7 @@ import (
"os"
"github.com/imgproxy/imgproxy/v3/asyncbuffer"
"github.com/imgproxy/imgproxy/v3/imagefetcher"
"github.com/imgproxy/imgproxy/v3/fetcher"
"github.com/imgproxy/imgproxy/v3/imagetype"
"github.com/imgproxy/imgproxy/v3/security"
)
@@ -63,7 +63,7 @@ func NewFromBase64(encoded string) (ImageData, error) {
}
// sendRequest is a common logic between sync and async download.
func sendRequest(ctx context.Context, url string, opts DownloadOptions) (*imagefetcher.Request, *http.Response, http.Header, error) {
func sendRequest(ctx context.Context, url string, opts DownloadOptions) (*fetcher.Request, *http.Response, http.Header, error) {
h := make(http.Header)
// NOTE: This will be removed in the future when our test context gets better isolation