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

Function writeAPISection

internal/logging/request_logger.go:1179–1206  ·  view source on GitHub ↗
(w io.Writer, sectionHeader string, sectionPrefix string, payload []byte, timestamp time.Time)

Source from the content-addressed store, hash-verified

1177}
1178
1179func writeAPISection(w io.Writer, sectionHeader string, sectionPrefix string, payload []byte, timestamp time.Time) error {
1180 if len(payload) == 0 {
1181 return nil
1182 }
1183
1184 if bytes.HasPrefix(payload, []byte(sectionPrefix)) {
1185 if _, errWrite := w.Write(payload); errWrite != nil {
1186 return errWrite
1187 }
1188 } else {
1189 if _, errWrite := io.WriteString(w, sectionHeader); errWrite != nil {
1190 return errWrite
1191 }
1192 if !timestamp.IsZero() {
1193 if _, errWrite := io.WriteString(w, fmt.Sprintf("Timestamp: %s\n", timestamp.Format(time.RFC3339Nano))); errWrite != nil {
1194 return errWrite
1195 }
1196 }
1197 if _, errWrite := w.Write(payload); errWrite != nil {
1198 return errWrite
1199 }
1200 }
1201
1202 if errWrite := writeSectionSpacing(w, countTrailingNewlinesBytes(payload)); errWrite != nil {
1203 return errWrite
1204 }
1205 return nil
1206}
1207
1208func writeAPISectionWithSource(w io.Writer, sectionHeader string, sectionPrefix string, payload []byte, source *FileBodySource, timestamp time.Time) error {
1209 if !hasFileBodySourcePayload(source) {

Callers 4

writeFinalLogMethod · 0.85
CloseMethod · 0.85

Calls 5

writeSectionSpacingFunction · 0.85
WriteStringMethod · 0.80
FormatMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected