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

Function writeAPISectionWithSource

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

Source from the content-addressed store, hash-verified

1206}
1207
1208func writeAPISectionWithSource(w io.Writer, sectionHeader string, sectionPrefix string, payload []byte, source *FileBodySource, timestamp time.Time) error {
1209 if !hasFileBodySourcePayload(source) {
1210 return writeAPISection(w, sectionHeader, sectionPrefix, payload, timestamp)
1211 }
1212 if len(payload) > 0 {
1213 if errWrite := writeAPISection(w, sectionHeader, sectionPrefix, payload, timestamp); errWrite != nil {
1214 return errWrite
1215 }
1216 }
1217 if _, errWrite := io.WriteString(w, sectionHeader); errWrite != nil {
1218 return errWrite
1219 }
1220 if !timestamp.IsZero() {
1221 if _, errWrite := io.WriteString(w, fmt.Sprintf("Timestamp: %s\n", timestamp.Format(time.RFC3339Nano))); errWrite != nil {
1222 return errWrite
1223 }
1224 }
1225 tracker := &trailingNewlineTrackingWriter{writer: w}
1226 if errWrite := source.WriteTo(tracker); errWrite != nil {
1227 return errWrite
1228 }
1229 if errWrite := writeSectionSpacing(w, tracker.trailingNewlines); errWrite != nil {
1230 return errWrite
1231 }
1232 return nil
1233}
1234
1235func writePreformattedAPISectionWithSource(w io.Writer, sectionHeader string, sectionPrefix string, payload []byte, source *FileBodySource, timestamp time.Time) error {
1236 if !hasFileBodySourcePayload(source) {

Callers 1

writeNonStreamingLogMethod · 0.85

Calls 6

hasFileBodySourcePayloadFunction · 0.85
writeAPISectionFunction · 0.85
writeSectionSpacingFunction · 0.85
WriteStringMethod · 0.80
FormatMethod · 0.80
WriteToMethod · 0.80

Tested by

no test coverage detected