Skip to content

Commit

Permalink
refactor function name
Browse files Browse the repository at this point in the history
  • Loading branch information
ariary committed Sep 23, 2022
1 parent c2833d6 commit 0d3f7e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ func Redirect(cfg *config.ClientConfig, response response.Response) (redirectRes
}
cfg.AddrPort = addr
path := "/" + strings.Join(strings.Split(location, "/")[4:], "/")
cfg.Request.ChangePath(path)
cfg.Request.SetPath(path)
//Update Host
cfg.Request.Headers["Host"] = []string{strings.Split(cfg.AddrPort, ":")[0]}
default:
cfg.Request.ChangePath(location)
cfg.Request.SetPath(location)
}

cfg.Request.ChangeMethod("GET")
cfg.Request.SetMethod("GET")
// add cookie if present
if cookies := response.Cookies; len(cookies) > 0 {
for i := 0; i < len(cookies); i++ {
Expand Down
8 changes: 4 additions & 4 deletions pkg/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ func GetRawHTTPRequest(req Request) (rawRequest []byte) {
return rawRequest
}

//ChangePath: Change the path uri with the one provided for the HTTP Request (modify first line of the raw request)
func (request *Request) ChangePath(path string) {
//SetPath: Change the path uri with the one provided for the HTTP Request (modify first line of the raw request)
func (request *Request) SetPath(path string) {
commandLineSplitted := strings.Split(request.CommandLine, " ") //(0: medthod, 1:path 2: version)
commandLineSplitted[1] = path
request.CommandLine = strings.Join(commandLineSplitted, " ")

}

//ChangeMethod: Change the method for the HTTP Request (modify first line of the raw request + request obect)
func (request *Request) ChangeMethod(nMethod string) {
//SetMethod: Change the method for the HTTP Request (modify first line of the raw request + request obect)
func (request *Request) SetMethod(nMethod string) {
request.Method = nMethod
commandLineSplitted := strings.Split(request.CommandLine, " ") //(0: medthod, 1:path 2: version)
commandLineSplitted[0] = nMethod
Expand Down

0 comments on commit 0d3f7e8

Please sign in to comment.