Skip to content

Commit

Permalink
Merge branch 'hotfix/content_type_header'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Hnatiw committed Oct 2, 2017
2 parents 592d165 + f59ef88 commit e53f848
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion racer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
Expand Down

0 comments on commit e53f848

Please sign in to comment.