MCPcopy Index your code
hub / github.com/php/frankenphp / ServeHTTP

Function ServeHTTP

frankenphp.go:392–424  ·  view source on GitHub ↗

ServeHTTP executes a PHP script according to the given context.

(responseWriter http.ResponseWriter, request *http.Request)

Source from the content-addressed store, hash-verified

390
391// ServeHTTP executes a PHP script according to the given context.
392func ServeHTTP(responseWriter http.ResponseWriter, request *http.Request) error {
393 h := responseWriter.Header()
394 if h["Server"] == nil {
395 h["Server"] = serverHeader
396 }
397
398 if !isRunning {
399 return ErrNotRunning
400 }
401
402 ctx := request.Context()
403 fc, ok := fromContext(ctx)
404
405 ch := contextHolder{ctx, fc}
406
407 if !ok {
408 return ErrInvalidRequest
409 }
410
411 fc.responseWriter = responseWriter
412
413 if err := fc.validate(); err != nil {
414 return err
415 }
416
417 // Detect if a worker is available to handle this request
418 if fc.worker != nil {
419 return fc.worker.handleRequest(ch)
420 }
421
422 // If no worker was available, send the request to non-worker threads
423 return handleRequestWithRegularPHPThreads(ch)
424}
425
426//export go_ub_write
427func go_ub_write(threadIndex C.uintptr_t, cBuf *C.char, length C.size_t) (C.size_t, C.bool) {

Callers 15

runTestFunction · 0.92
testPathInfoFunction · 0.92
ExampleServeHTTPFunction · 0.92
BenchmarkHelloWorldFunction · 0.92
BenchmarkEchoFunction · 0.92
BenchmarkUncommonHeadersFunction · 0.92
ExampleServeHTTP_workersFunction · 0.92
testRegisterExtensionFunction · 0.92
mainFunction · 0.92
module.goFile · 0.92

Calls 5

fromContextFunction · 0.85
HeaderMethod · 0.80
validateMethod · 0.80
handleRequestMethod · 0.80

Tested by 11

runTestFunction · 0.74
testPathInfoFunction · 0.74
ExampleServeHTTPFunction · 0.74
BenchmarkHelloWorldFunction · 0.74
BenchmarkEchoFunction · 0.74
BenchmarkUncommonHeadersFunction · 0.74
ExampleServeHTTP_workersFunction · 0.74
assertRequestBodyFunction · 0.68