MCPcopy Create free account
hub / github.com/axetroy/forward-cli / modifyContent

Method modifyContent

proxy.go:194–208  ·  view source on GitHub ↗
(extNames []string, body []byte, originHost string, proxyHost string)

Source from the content-addressed store, hash-verified

192}
193
194func (p *ProxyServer) modifyContent(extNames []string, body []byte, originHost string, proxyHost string) []byte {
195 bodyStr := string(body)
196
197 bodyStr = replaceHost(bodyStr, originHost, proxyHost, p.UseSSL, p.ProxyExternal, p.ProxyExternalIgnores)
198
199 // https://developer.mozilla.org/zh-CN/docs/Web/Security/Subresource_Integrity
200 if isHtml(extNames) {
201 bodyStr = regIntegrity.ReplaceAllString(bodyStr, "")
202
203 // <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">
204 bodyStr = strings.ReplaceAll(bodyStr, `http-equiv="Content-Security-Policy"`, "") // disabled CSP
205 }
206
207 return []byte(bodyStr)
208}
209
210func (p *ProxyServer) modifyResponse(res *http.Response) error {
211 target := *p.Target

Callers 1

modifyResponseMethod · 0.95

Calls 2

replaceHostFunction · 0.85
isHtmlFunction · 0.85

Tested by

no test coverage detected