MCPcopy Index your code
hub / github.com/dreadl0ck/netcap / writeHTTP

Function writeHTTP

decoder/stream/http/http_reader.go:232–278  ·  view source on GitHub ↗
(h *types.HTTP, ident string)

Source from the content-addressed store, hash-verified

230}
231
232func writeHTTP(h *types.HTTP, ident string) {
233 // TODO: this kills performance, make configurable
234 // updateHTTPStore(h)
235
236 if decoderconfig.Instance.IncludePayloads {
237 // TODO: only include request body, not the entire stream contents...
238 // h.RequestBody = t.client.DataSlice().bytes()
239 // h.ResponseBody = t.server.DataSlice().bytes()
240 }
241
242 // export metrics if configured
243 if decoderconfig.Instance.ExportMetrics {
244 h.Inc()
245 }
246
247 // write record to disk
248 atomic.AddInt64(&Decoder.NumRecordsWritten, 1)
249 err := Decoder.Writer.Write(h)
250 if err != nil {
251 decoderutils.ErrorMap.Inc(err.Error())
252 }
253
254 soft := software.WhatSoftwareHTTP(ident, h)
255
256 if len(soft) == 0 {
257 return
258 }
259
260 communityID := h.CommunityID
261 software.WriteSoftware(soft, func(s *software.AtomicSoftware) {
262 s.Lock()
263 // Check if flow already exists
264 flowExists := slices.Contains(s.Flows, ident)
265 // Add flow if not exists
266 if !flowExists {
267 s.Flows = append(s.Flows, ident)
268 }
269 // Add community ID if not exists
270 if communityID != "" {
271 cidExists := slices.Contains(s.CommunityIDs, communityID)
272 if !cidExists {
273 s.CommunityIDs = append(s.CommunityIDs, communityID)
274 }
275 }
276 s.Unlock()
277 })
278}
279
280// HTTP Response
281

Callers 1

DecodeMethod · 0.85

Calls 5

WhatSoftwareHTTPFunction · 0.92
WriteSoftwareFunction · 0.92
IncMethod · 0.65
WriteMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected