add response / request modifier API to only fire once

This commit is contained in:
Kevin Pham
2023-11-26 23:15:00 -06:00
parent a295f2a167
commit fb63dba8a0
9 changed files with 44 additions and 56 deletions

View File

@@ -2,6 +2,7 @@ package requestmodifers
import (
"ladder/proxychain"
"net/url"
)
// ModifyQueryParams replaces query parameter values in URL's query params in a ProxyChain's URL.
@@ -9,12 +10,16 @@ import (
func ModifyQueryParams(key string, value string) proxychain.RequestModification {
return func(px *proxychain.ProxyChain) error {
q := px.Request.URL.Query()
if value == "" {
q.Del(key)
return nil
}
q.Set(key, value)
px.Request.URL.RawQuery = q.Encode()
px.Request.URL.RawQuery = modifyQueryParams(key, value, q)
return nil
}
}
func modifyQueryParams(key string, value string, q url.Values) string {
if value == "" {
q.Del(key)
return q.Encode()
}
q.Set(key, value)
return q.Encode()
}