Skip to content

Commit

Permalink
Removed unused params
Browse files Browse the repository at this point in the history
  • Loading branch information
evg4b committed Jan 4, 2024
1 parent 794a148 commit 4bf4400
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
10 changes: 2 additions & 8 deletions internal/handler/proxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,18 @@ func (h *Handler) executeQuery(request *http.Request) (*http.Response, error) {
return originalResponse, nil
}

// nolint: unparam
func copyCookiesToSource(target *http.Response, replacer *urlreplacer.Replacer, source http.ResponseWriter) error {
func copyCookiesToSource(target *http.Response, replacer *urlreplacer.Replacer, source http.ResponseWriter) {
for _, cookie := range target.Cookies() {
cookie.Secure = replacer.IsTargetSecure()
cookie.Domain = replacer.ReplaceSoft(cookie.Domain)
http.SetCookie(source, cookie)
}

return nil
}

// nolint: unparam
func copyCookiesToTarget(source *http.Request, replacer *urlreplacer.Replacer, target *http.Request) error {
func copyCookiesToTarget(source *http.Request, replacer *urlreplacer.Replacer, target *http.Request) {
for _, cookie := range source.Cookies() {
cookie.Secure = replacer.IsTargetSecure()
cookie.Domain = replacer.ReplaceSoft(cookie.Domain)
target.AddCookie(cookie)
}

return nil
}
4 changes: 1 addition & 3 deletions internal/handler/proxy/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ func (h *Handler) makeOriginalRequest(
return nil, err
}

if err = copyCookiesToTarget(req, replacer, originalRequest); err != nil {
return nil, fmt.Errorf("failed to copy cookies in request: %w", err)
}
copyCookiesToTarget(req, replacer, originalRequest)

return originalRequest, nil
}
4 changes: 1 addition & 3 deletions internal/handler/proxy/responce.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ func (h *Handler) makeUncorsResponse(
target http.ResponseWriter,
replacer *urlreplacer.Replacer,
) error {
if err := copyCookiesToSource(original, replacer, target); err != nil {
return fmt.Errorf("failed to copy cookies in request: %w", err)
}
copyCookiesToSource(original, replacer, target)

modifications := modificationsMap{
headers.Location: func(s string) (string, error) { // nolint: unparam
Expand Down

0 comments on commit 4bf4400

Please sign in to comment.