export go_ub_write
(threadIndex C.uintptr_t, cBuf *C.char, length C.size_t)
| 425 | |
| 426 | //export go_ub_write |
| 427 | func go_ub_write(threadIndex C.uintptr_t, cBuf *C.char, length C.size_t) (C.size_t, C.bool) { |
| 428 | thread := phpThreads[threadIndex] |
| 429 | fc := thread.frankenPHPContext() |
| 430 | |
| 431 | if fc.isDone { |
| 432 | return 0, C.bool(true) |
| 433 | } |
| 434 | |
| 435 | var writer io.Writer |
| 436 | if fc.responseWriter == nil { |
| 437 | var b bytes.Buffer |
| 438 | // log the output of the worker |
| 439 | writer = &b |
| 440 | } else { |
| 441 | writer = fc.responseWriter |
| 442 | } |
| 443 | |
| 444 | var ctx context.Context |
| 445 | |
| 446 | i, e := writer.Write(unsafe.Slice((*byte)(unsafe.Pointer(cBuf)), length)) |
| 447 | if e != nil { |
| 448 | ctx = thread.context() |
| 449 | |
| 450 | if fc.logger.Enabled(ctx, slog.LevelWarn) { |
| 451 | fc.logger.LogAttrs(ctx, slog.LevelWarn, "write error", slog.Any("error", e)) |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | if fc.responseWriter == nil { |
| 456 | // probably starting a worker script, log the output |
| 457 | |
| 458 | if ctx == nil { |
| 459 | ctx = thread.context() |
| 460 | } |
| 461 | |
| 462 | if fc.logger.Enabled(ctx, slog.LevelInfo) { |
| 463 | fc.logger.LogAttrs(ctx, slog.LevelInfo, writer.(*bytes.Buffer).String()) |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | return C.size_t(i), C.bool(fc.clientHasClosed()) |
| 468 | } |
| 469 | |
| 470 | //export go_apache_request_headers |
| 471 | func go_apache_request_headers(threadIndex C.uintptr_t) (*C.go_string, C.size_t) { |
nothing calls this directly
no test coverage detected