Skip to content

Commit

Permalink
doc: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
bcho committed Aug 18, 2023
1 parent b51f286 commit 7bb7c5c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package turtle

import (
"context"
"net/http"
"net/url"
"time"
)

func ExampleSlowloris() {
u, err := url.Parse("http://127.0.0.1:8080")
if err != nil {
panic(err)
}

s := Slowloris{
Target: Target{
Url: *u,
},
SendGibberish: true,
GibberishInterval: 5 * time.Millisecond,
UserAgents: []string{
"turtle/0.0.1",
"turtle/0.0.1 - slowloris",
},
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

_ = s.Run(ctx)
}

func ExampleSlowBodyReadRequest() {
u, err := url.Parse("http://127.0.0.1:8080")
if err != nil {
panic(err)
}

s := SlowBodyReadRequest{
Target: Target{
Url: *u,
},
Method: http.MethodPost,
BodyReadTimeout: 180 * time.Second,
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

_ = s.Run(ctx)
}

0 comments on commit 7bb7c5c

Please sign in to comment.