MCPcopy
hub / github.com/dgraph-io/dgraph / getRequestBody

Function getRequestBody

audit/interceptor.go:350–370  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

348}
349
350func getRequestBody(r *http.Request) []byte {
351 var in io.Reader = r.Body
352 if enc := r.Header.Get("Content-Encoding"); enc != "" && enc != "identity" {
353 if enc == "gzip" {
354 gz, err := gzip.NewReader(r.Body)
355 if err != nil {
356 return []byte(err.Error())
357 }
358 defer gz.Close()
359 in = gz
360 } else {
361 return []byte("unknown encoding")
362 }
363 }
364
365 body, err := io.ReadAll(in)
366 if err != nil {
367 return []byte(err.Error())
368 }
369 return body
370}
371
372func getUser(token string, poorman bool) string {
373 if poorman {

Callers 1

auditHttpFunction · 0.85

Calls 3

GetMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected