MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / writeRequestInfoWithBody

Function writeRequestInfoWithBody

internal/logging/request_logger.go:989–1079  ·  view source on GitHub ↗
(
	w io.Writer,
	url, method string,
	headers map[string][]string,
	body []byte,
	bodyPath string,
	timestamp time.Time,
	downstreamTransport string,
	upstreamTransport string,
	includeBody bool,
)

Source from the content-addressed store, hash-verified

987}
988
989func writeRequestInfoWithBody(
990 w io.Writer,
991 url, method string,
992 headers map[string][]string,
993 body []byte,
994 bodyPath string,
995 timestamp time.Time,
996 downstreamTransport string,
997 upstreamTransport string,
998 includeBody bool,
999) error {
1000 if _, errWrite := io.WriteString(w, "=== REQUEST INFO ===\n"); errWrite != nil {
1001 return errWrite
1002 }
1003 if _, errWrite := io.WriteString(w, fmt.Sprintf("Version: %s\n", buildinfo.Version)); errWrite != nil {
1004 return errWrite
1005 }
1006 if _, errWrite := io.WriteString(w, fmt.Sprintf("URL: %s\n", url)); errWrite != nil {
1007 return errWrite
1008 }
1009 if _, errWrite := io.WriteString(w, fmt.Sprintf("Method: %s\n", method)); errWrite != nil {
1010 return errWrite
1011 }
1012 if strings.TrimSpace(downstreamTransport) != "" {
1013 if _, errWrite := io.WriteString(w, fmt.Sprintf("Downstream Transport: %s\n", downstreamTransport)); errWrite != nil {
1014 return errWrite
1015 }
1016 }
1017 if strings.TrimSpace(upstreamTransport) != "" {
1018 if _, errWrite := io.WriteString(w, fmt.Sprintf("Upstream Transport: %s\n", upstreamTransport)); errWrite != nil {
1019 return errWrite
1020 }
1021 }
1022 if _, errWrite := io.WriteString(w, fmt.Sprintf("Timestamp: %s\n", timestamp.Format(time.RFC3339Nano))); errWrite != nil {
1023 return errWrite
1024 }
1025 if errWrite := writeSectionSpacing(w, 1); errWrite != nil {
1026 return errWrite
1027 }
1028
1029 if _, errWrite := io.WriteString(w, "=== HEADERS ===\n"); errWrite != nil {
1030 return errWrite
1031 }
1032 for key, values := range headers {
1033 for _, value := range values {
1034 masked := util.MaskSensitiveHeaderValue(key, value)
1035 if _, errWrite := io.WriteString(w, fmt.Sprintf("%s: %s\n", key, masked)); errWrite != nil {
1036 return errWrite
1037 }
1038 }
1039 }
1040 if errWrite := writeSectionSpacing(w, 1); errWrite != nil {
1041 return errWrite
1042 }
1043
1044 if !includeBody {
1045 return nil
1046 }

Callers 3

writeNonStreamingLogMethod · 0.85
writeFinalLogMethod · 0.85
CloseMethod · 0.85

Calls 8

MaskSensitiveHeaderValueFunction · 0.92
writeSectionSpacingFunction · 0.85
WriteStringMethod · 0.80
FormatMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected