|
|
@ -108,6 +108,8 @@ func NewProxyURLOptions(opts ...Option) *Options {
|
|
|
|
return o
|
|
|
|
return o
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const sliceSize = 1024 * 1024
|
|
|
|
|
|
|
|
|
|
|
|
func URL(ctx *gin.Context, u string, headers map[string]string, opts ...Option) error {
|
|
|
|
func URL(ctx *gin.Context, u string, headers map[string]string, opts ...Option) error {
|
|
|
|
o := NewProxyURLOptions(opts...)
|
|
|
|
o := NewProxyURLOptions(opts...)
|
|
|
|
if !settings.AllowProxyToLocal.Get() {
|
|
|
|
if !settings.AllowProxyToLocal.Get() {
|
|
|
@ -134,12 +136,13 @@ func URL(ctx *gin.Context, u string, headers map[string]string, opts ...Option)
|
|
|
|
rsc := NewHTTPReadSeekCloser(u,
|
|
|
|
rsc := NewHTTPReadSeekCloser(u,
|
|
|
|
WithContext(c),
|
|
|
|
WithContext(c),
|
|
|
|
WithHeadersMap(headers),
|
|
|
|
WithHeadersMap(headers),
|
|
|
|
|
|
|
|
WithPerLength(sliceSize*2),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
defer rsc.Close()
|
|
|
|
defer rsc.Close()
|
|
|
|
if o.CacheKey == "" {
|
|
|
|
if o.CacheKey == "" {
|
|
|
|
o.CacheKey = u
|
|
|
|
o.CacheKey = u
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NewSliceCacheProxy(o.CacheKey, 1024*512, rsc, getCache()).
|
|
|
|
return NewSliceCacheProxy(o.CacheKey, sliceSize, rsc, getCache()).
|
|
|
|
Proxy(ctx.Writer, ctx.Request)
|
|
|
|
Proxy(ctx.Writer, ctx.Request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|