(cache *CacheStruct, headerList []string)
| 449 | } |
| 450 | |
| 451 | func cachebusterHeader(cache *CacheStruct, headerList []string) []error { |
| 452 | headers := []string{} |
| 453 | values := []string{} |
| 454 | if len(headerList) > 0 { |
| 455 | headers = append(headers, headerList...) |
| 456 | } else { |
| 457 | headers = append(headers, "Accept-Encoding", "Accept", "Cookie", "Origin") |
| 458 | values = append(values, "gzip, deflate, ", "*/*, text/", "wcvs_cookie=") |
| 459 | for _, header := range Config.Headers { |
| 460 | headers = append(headers, strings.TrimSpace(strings.Split(header, ":")[0])) // Only add headername |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | var errSlice []error |
| 465 | |
| 466 | for i, header := range headers { |
| 467 | errorString := "cachebusterHeader " + header |
| 468 | identifier := "Header " + header + " as Cachebuster" |
| 469 | |
| 470 | if len(values) < i+1 { // prevent index out of range |
| 471 | values = append(values, "") |
| 472 | } |
| 473 | |
| 474 | if header == "" { // skip empty headers |
| 475 | continue |
| 476 | } |
| 477 | |
| 478 | req := fasthttp.AcquireRequest() |
| 479 | resp := fasthttp.AcquireResponse() |
| 480 | defer fasthttp.ReleaseRequest(req) |
| 481 | defer fasthttp.ReleaseResponse(resp) |
| 482 | var err error |
| 483 | var times []int64 |
| 484 | |
| 485 | if cache.Indicator == "" { |
| 486 | // No Cache Indicator was found. So time will be used as Indicator |
| 487 | |
| 488 | for ii := range 5 * 2 { |
| 489 | weburl := Config.Website.Url.String() |
| 490 | |
| 491 | if Config.DoPost { |
| 492 | req.Header.SetMethod("POST") |
| 493 | req.SetBodyString(Config.Body) |
| 494 | } else { |
| 495 | req.Header.SetMethod("GET") |
| 496 | if Config.Body != "" { |
| 497 | req.SetBodyString(Config.Body) |
| 498 | |
| 499 | } |
| 500 | } |
| 501 | req.SetRequestURI(weburl) |
| 502 | |
| 503 | setRequest(req, Config.DoPost, "", nil, false) |
| 504 | if ii%2 == 0 { |
| 505 | cbvalue := values[i] + "cb" + randInt() |
| 506 | if h := req.Header.Peek(header); h != nil { |
| 507 | msg := fmt.Sprintf("Overwriting %s:%s with %s:%s\n", header, h, header, cbvalue) |
| 508 | Print(msg, NoColor) |
no test coverage detected