Permalink
Browse files

Fixes #2

Checks for "Content-Type" header, adds if needed.
  • Loading branch information...
insp3ctre committed Oct 2, 2017
1 parent 592d165 commit f59ef888721a073e3102b37e88b77bd5a1e24cc7
Showing with 10 additions and 1 deletion.
  1. +10 −1 racer.go
@@ -260,17 +260,26 @@ func sendRequests() (responses chan ResponseInfo, errors chan error) {
req.Header.Add("Cookie", cookieStr)
}
// Track whether content-type header has been added
contentType := false
// Add custom headers to the request
for _, header := range t.Headers {
split := strings.Split(header, ":")
hKey := split[0]
hVal := split[1]
req.Header.Add(hKey, hVal)
// Check for Content-Type header
if strings.ToLower(hKey) == "content-type" {
contentType = true
fmt.Println("[DEBUG] Content-Type Found!")
}
}
// Add content-type to POST requests (some applications require this to properly process POST requests)
// TODO: Find any bugs around other request types
if t.Method == "POST" {
if !contentType && t.Method == "POST" {
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
}

0 comments on commit f59ef88

Please sign in to comment.