uint16 for HTTP Status codes

This commit is contained in:
Tomás Senart
2013-09-09 13:25:29 +01:00
parent 15ad005f5a
commit 2147e1840b
2 changed files with 3 additions and 3 deletions

View File

@@ -35,7 +35,7 @@ func Attack(targets Targets, rate uint64, duration time.Duration) []Result {
// Result represents the metrics we want out of an http.Response
type Result struct {
Code uint64
Code uint16
Timestamp time.Time
Timing time.Duration
BytesOut uint64
@@ -73,7 +73,7 @@ func hit(req *http.Request, res chan Result) {
Error: err,
}
if err == nil {
result.Code = uint64(r.StatusCode)
result.Code = uint16(r.StatusCode)
if body, err := ioutil.ReadAll(r.Body); err != nil {
if result.Code < 200 || result.Code >= 300 {
result.Error = errors.New(string(body))

View File

@@ -26,7 +26,7 @@ func ReportText(results []Result, out io.Writer) error {
totalBytesOut := uint64(0)
totalBytesIn := uint64(0)
totalSuccess := uint64(0)
histogram := map[uint64]uint64{}
histogram := map[uint16]uint64{}
errors := map[string]struct{}{}
for _, res := range results {