GetHeaders (a.k.a GetReqHeaders) returns the HTTP request headers. Returned value is only valid within the handler. Do not store any references. Make copies or use the Immutable setting instead.
()
| 489 | // Returned value is only valid within the handler. Do not store any references. |
| 490 | // Make copies or use the Immutable setting instead. |
| 491 | func (r *DefaultReq) GetHeaders() map[string][]string { |
| 492 | app := r.c.app |
| 493 | reqHeader := &r.c.fasthttp.Request.Header |
| 494 | // Pre-allocate map with known header count to avoid reallocations |
| 495 | headers := make(map[string][]string, reqHeader.Len()) |
| 496 | for k, v := range reqHeader.All() { |
| 497 | key := app.toString(k) |
| 498 | headers[key] = append(headers[key], app.toString(v)) |
| 499 | } |
| 500 | return headers |
| 501 | } |
| 502 | |
| 503 | // Host contains the host derived from the X-Forwarded-Host or Host HTTP header. |
| 504 | // Returned value is only valid within the handler. Do not store any references. |