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

Function go_update_request_info

cgi.go:292–327  ·  view source on GitHub ↗

go_update_request_info updates the sapi_request_info struct See: https://github.com/php/php-src/blob/345e04b619c3bc11ea17ee02cdecad6ae8ce5891/main/SAPI.h#L72 export go_update_request_info

(threadIndex C.uintptr_t, info *C.sapi_request_info)

Source from the content-addressed store, hash-verified

290//
291//export go_update_request_info
292func go_update_request_info(threadIndex C.uintptr_t, info *C.sapi_request_info) *C.char {
293 thread := phpThreads[threadIndex]
294 fc := thread.frankenPHPContext()
295 request := fc.request
296
297 if request == nil {
298 return nil
299 }
300
301 if m, ok := cStringHTTPMethods[request.Method]; ok {
302 info.request_method = m
303 } else {
304 info.request_method = thread.pinCString(request.Method)
305 }
306 info.query_string = thread.pinCString(request.URL.RawQuery)
307 info.content_length = C.zend_long(request.ContentLength)
308
309 if contentType := request.Header.Get("Content-Type"); contentType != "" {
310 info.content_type = thread.pinCString(contentType)
311 }
312
313 if fc.pathInfo != "" {
314 info.path_translated = thread.pinCString(sanitizedPathJoin(fc.documentRoot, fc.pathInfo)) // See: http://www.oreilly.com/openbook/cgi/ch02_04.html
315 }
316
317 info.request_uri = thread.pinCString(fc.requestURI)
318
319 info.proto_num = C.int(request.ProtoMajor*1000 + request.ProtoMinor)
320
321 authorizationHeader := request.Header.Get("Authorization")
322 if authorizationHeader == "" {
323 return nil
324 }
325
326 return thread.pinCString(authorizationHeader)
327}
328
329// SanitizedPathJoin performs filepath.Join(root, reqPath) that
330// is safe against directory traversal attacks. It uses logic

Callers

nothing calls this directly

Calls 4

sanitizedPathJoinFunction · 0.85
pinCStringMethod · 0.80
GetMethod · 0.80
frankenPHPContextMethod · 0.65

Tested by

no test coverage detected