Skip to content

Commit

Permalink
feat(helpers): net_packet_http request/response
Browse files Browse the repository at this point in the history
- Add `GetProtoHTTPRequestByName` to get http request header from the
  event `net_packet_http_request`;
- Add `GetProtoHTTPResponseByName` to get http response header from the
  event `net_packet_http_response`;
  • Loading branch information
rscampos committed Nov 27, 2024
1 parent 19384bb commit d1a6507
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions signatures/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,41 @@ func GetProtoHTTPByName(

return trace.ProtoHTTP{}, fmt.Errorf("protocol HTTP: type error (should be trace.ProtoHTTP, is %T)", arg.Value)
}

func GetProtoHTTPRequestByName(
event trace.Event,
argName string,
) (
trace.ProtoHTTPRequest, error,
) {
arg, err := GetTraceeArgumentByName(event, argName, GetArgOps{DefaultArgs: false})
if err != nil {
return trace.ProtoHTTPRequest{}, err
}

argProtoHTTPRequest, ok := arg.Value.(trace.ProtoHTTPRequest)
if ok {
return argProtoHTTPRequest, nil
}

return trace.ProtoHTTPRequest{}, fmt.Errorf("protocol HTTP (request): type error (should be trace.ProtoHTTPRequest, is %T)", arg.Value)
}

func GetProtoHTTPResponseByName(
event trace.Event,
argName string,
) (
trace.ProtoHTTPResponse, error,
) {
arg, err := GetTraceeArgumentByName(event, argName, GetArgOps{DefaultArgs: false})
if err != nil {
return trace.ProtoHTTPResponse{}, err
}

argProtoHTTPResponse, ok := arg.Value.(trace.ProtoHTTPResponse)
if ok {
return argProtoHTTPResponse, nil
}

return trace.ProtoHTTPResponse{}, fmt.Errorf("protocol HTTP (response): type error (should be trace.ProtoHTTPResponse, is %T)", arg.Value)
}

0 comments on commit d1a6507

Please sign in to comment.