fix content-type not set regression on main proxy handler
This commit is contained in:
@@ -20,6 +20,7 @@ func NewOutlineHandler(path string, opts *ProxyOptions) fiber.Handler {
|
|||||||
rx.SpoofReferrerFromGoogleSearch(),
|
rx.SpoofReferrerFromGoogleSearch(),
|
||||||
).
|
).
|
||||||
AddResponseModifications(
|
AddResponseModifications(
|
||||||
|
tx.ForwardResponseHeaders(),
|
||||||
tx.DeleteIncomingCookies(),
|
tx.DeleteIncomingCookies(),
|
||||||
tx.RewriteHTMLResourceURLs(),
|
tx.RewriteHTMLResourceURLs(),
|
||||||
tx.GenerateReadableOutline(), // <-- this response modification does the outline rendering
|
tx.GenerateReadableOutline(), // <-- this response modification does the outline rendering
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
|
|||||||
//rx.RequestArchiveIs(),
|
//rx.RequestArchiveIs(),
|
||||||
).
|
).
|
||||||
AddResponseModifications(
|
AddResponseModifications(
|
||||||
//tx.ForwardResponseHeaders(),
|
tx.ForwardResponseHeaders(),
|
||||||
//tx.BlockThirdPartyScripts(),
|
//tx.BlockThirdPartyScripts(),
|
||||||
tx.DeleteIncomingCookies(),
|
tx.DeleteIncomingCookies(),
|
||||||
tx.DeleteLocalStorageData(),
|
tx.DeleteLocalStorageData(),
|
||||||
@@ -53,11 +53,16 @@ func NewProxySiteHandler(opts *ProxyOptions) fiber.Handler {
|
|||||||
tx.RewriteHTMLResourceURLs(),
|
tx.RewriteHTMLResourceURLs(),
|
||||||
tx.PatchDynamicResourceURLs(),
|
tx.PatchDynamicResourceURLs(),
|
||||||
tx.PatchTrackerScripts(),
|
tx.PatchTrackerScripts(),
|
||||||
//tx.BlockElementRemoval(".article-content"), // techcrunch
|
tx.BlockElementRemoval(".article-content"), // techcrunch
|
||||||
tx.BlockElementRemoval(".available-content"), // substack
|
//tx.BlockElementRemoval(".available-content"), // substack
|
||||||
// tx.SetContentSecurityPolicy("default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"),
|
// tx.SetContentSecurityPolicy("default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// no options passed in, return early
|
||||||
|
if opts == nil {
|
||||||
|
return proxychain.Execute()
|
||||||
|
}
|
||||||
|
|
||||||
// load ruleset
|
// load ruleset
|
||||||
rule, exists := opts.Ruleset.GetRule(proxychain.Request.URL)
|
rule, exists := opts.Ruleset.GetRule(proxychain.Request.URL)
|
||||||
if exists {
|
if exists {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func NewRulesetSiteHandler(opts *ProxyOptions) fiber.Handler {
|
|||||||
return c.Send([]byte(jsn))
|
return c.Send([]byte(jsn))
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// TODO: the ruleset.MarshalYAML() method is currently broken and panics
|
|
||||||
yml, err := opts.Ruleset.YAML()
|
yml, err := opts.Ruleset.YAML()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -525,12 +525,14 @@ func (chain *ProxyChain) Execute() error {
|
|||||||
return errors.New("no context set")
|
return errors.New("no context set")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: this seems broken
|
||||||
// in case api user did not set or forward content-type, we do it for them
|
// in case api user did not set or forward content-type, we do it for them
|
||||||
ct := chain.Context.Response().Header.Peek("content-type")
|
/*
|
||||||
CT := chain.Context.Response().Header.Peek("Content-Type")
|
ct := string(chain.Context.Response().Header.Peek("content-type"))
|
||||||
if ct == nil && CT == nil {
|
if ct == "" {
|
||||||
chain.Context.Set("content-type", chain.Response.Header.Get("content-type"))
|
chain.Context.Set("content-type", chain.Response.Header.Get("content-type"))
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Return request back to client
|
// Return request back to client
|
||||||
return chain.Context.SendStream(body)
|
return chain.Context.SendStream(body)
|
||||||
|
|||||||
Reference in New Issue
Block a user