Skip to content

Commit

Permalink
Merge pull request #81 from ddosify/x-ddosify-res-time_header_accept
Browse files Browse the repository at this point in the history
add ddResTime to Custom field of ResponseItem
  • Loading branch information
kursataktas authored Sep 8, 2022
2 parents a69b697 + 687546d commit eddadbb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/scenario/requester/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"net/http/httptrace"
"net/url"
"regexp"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -179,6 +180,12 @@ func (h *HttpRequester) Send() (res *types.ResponseItem) {
httpRes.Body.Close()
}

var ddResTime time.Duration
if httpRes != nil && httpRes.Header.Get("x-ddsfy-response-time") != "" {
resTime, _ := strconv.ParseFloat(httpRes.Header.Get("x-ddsfy-response-time"), 8)
ddResTime = time.Duration(resTime*1000) * time.Millisecond
}

// Finalize
res = &types.ResponseItem{
ScenarioItemID: h.packet.ID,
Expand All @@ -200,6 +207,9 @@ func (h *HttpRequester) Send() (res *types.ResponseItem) {
if h.packet.Protocol == types.ProtocolHTTPS {
res.Custom["tlsDuration"] = durations.getTLSDur()
}
if ddResTime != 0 {
res.Custom["ddResponseTime"] = ddResTime
}

return
}
Expand Down

0 comments on commit eddadbb

Please sign in to comment.