(extNames []string, body []byte, originHost string, proxyHost string)
| 192 | } |
| 193 | |
| 194 | func (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 | |
| 210 | func (p *ProxyServer) modifyResponse(res *http.Response) error { |
| 211 | target := *p.Target |
no test coverage detected