export go_apache_request_headers
(threadIndex C.uintptr_t)
| 469 | |
| 470 | //export go_apache_request_headers |
| 471 | func go_apache_request_headers(threadIndex C.uintptr_t) (*C.go_string, C.size_t) { |
| 472 | thread := phpThreads[threadIndex] |
| 473 | ctx := thread.context() |
| 474 | fc := thread.frankenPHPContext() |
| 475 | |
| 476 | if fc.responseWriter == nil { |
| 477 | // worker mode, not handling a request |
| 478 | |
| 479 | if globalLogger.Enabled(ctx, slog.LevelDebug) { |
| 480 | globalLogger.LogAttrs(ctx, slog.LevelDebug, "apache_request_headers() called in non-HTTP context", slog.String("worker", fc.worker.name)) |
| 481 | } |
| 482 | |
| 483 | return nil, 0 |
| 484 | } |
| 485 | |
| 486 | headers := make([]C.go_string, 0, len(fc.request.Header)*2) |
| 487 | |
| 488 | for field, val := range fc.request.Header { |
| 489 | fd := unsafe.StringData(field) |
| 490 | thread.Pin(fd) |
| 491 | |
| 492 | cv := strings.Join(val, ", ") |
| 493 | vd := unsafe.StringData(cv) |
| 494 | thread.Pin(vd) |
| 495 | |
| 496 | headers = append( |
| 497 | headers, |
| 498 | C.go_string{C.size_t(len(field)), (*C.char)(unsafe.Pointer(fd))}, |
| 499 | C.go_string{C.size_t(len(cv)), (*C.char)(unsafe.Pointer(vd))}, |
| 500 | ) |
| 501 | } |
| 502 | |
| 503 | sd := unsafe.SliceData(headers) |
| 504 | thread.Pin(sd) |
| 505 | |
| 506 | return sd, C.size_t(len(fc.request.Header)) |
| 507 | } |
| 508 | |
| 509 | func addHeader(ctx context.Context, fc *frankenPHPContext, h *C.sapi_header_struct) { |
| 510 | key, val := splitRawHeader(h.header, int(h.header_len)) |
nothing calls this directly
no test coverage detected