-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from buger/raw-http-client
Send unmodified http request
- Loading branch information
Showing
29 changed files
with
1,037 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
SOURCE = emitter.go gor.go gor_stat.go input_dummy.go input_file.go input_raw.go input_tcp.go limiter.go output_dummy.go output_file.go input_http.go output_http.go output_tcp.go plugins.go settings.go settings_header_filters.go settings_header_hash_filters.go settings_headers.go settings_methods.go settings_option.go settings_url_regexp.go test_input.go elasticsearch.go settings_url_map.go | ||
SOURCE = emitter.go gor.go gor_stat.go input_dummy.go input_file.go input_raw.go input_tcp.go limiter.go output_dummy.go output_file.go input_http.go output_http.go output_tcp.go plugins.go settings.go settings_header_filters.go settings_header_hash_filters.go settings_headers.go settings_methods.go settings_option.go settings_url_regexp.go test_input.go elasticsearch.go settings_url_map.go http_modifier.go | ||
|
||
SOURCE_PATH = /gopath/src/github.com/buger/gor/ | ||
|
||
release: release-x86 release-x64 | ||
|
||
release-x64: | ||
docker run -v `pwd`:/gopath/src/gor -t --env GOOS=linux --env GOARCH=amd64 --env CGO_ENABLED=0 -i gor go build && tar -czf gor_x64.tar.gz gor && rm gor | ||
docker run -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=amd64 --env CGO_ENABLED=0 -i gor go build && tar -czf gor_x64.tar.gz gor && rm gor | ||
|
||
release-x86: | ||
docker run -v `pwd`:/gopath/src/gor -t --env GOOS=linux --env GOARCH=386 --env CGO_ENABLED=0 -i gor go build && tar -czf gor_x86.tar.gz gor && rm gor | ||
docker run -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=386 --env CGO_ENABLED=0 -i gor go build && tar -czf gor_x86.tar.gz gor && rm gor | ||
|
||
dbuild: | ||
docker build -t gor . | ||
|
||
dtest: | ||
docker run -v `pwd`:/gopath/src/gor -t -i --env GORACE="halt_on_error=1" gor go test $(ARGS) -race -v | ||
docker run -v `pwd`:$(SOURCE_PATH) -t -i --env GORACE="halt_on_error=1" gor go test ./... $(ARGS) -race -v -timeout 15s | ||
|
||
dfmt: | ||
docker run -v `pwd`:/gopath/src/gor -t -i gor go fmt | ||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go fmt | ||
|
||
dvet: | ||
docker run -v `pwd`:/gopath/src/gor -t -i gor go vet | ||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go vet | ||
|
||
dbench: | ||
docker run -v `pwd`:/gopath/src/gor -t -i gor go test -v -run NOT_EXISTING -bench HTTP | ||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go test -v -run NOT_EXISTING -bench HTTP | ||
|
||
# Used mainly for debugging, because docker container do not have access to parent machine ports | ||
drun: | ||
docker run -v `pwd`:/gopath/src/gor -t -i gor go run $(SOURCE) --input-dummy=0 --input-http=:9000 --output-http="http://localhost:9000" --verbose | ||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-dummy=0 --output-http="http://localhost:9000" --verbose | ||
|
||
dbash: | ||
docker run -v `pwd`:/gopath/src/gor -t -i gor /bin/bash | ||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package byteutils | ||
|
||
func Cut(a []byte, from, to int) []byte { | ||
copy(a[from:], a[to:]) | ||
a = a[:len(a)-to+from] | ||
|
||
return a | ||
} | ||
|
||
func Insert(a []byte, i int, b []byte) []byte { | ||
a = append(a, make([]byte, len(b))...) | ||
copy(a[i+len(b):], a[i:]) | ||
copy(a[i:i+len(b)], b) | ||
|
||
return a | ||
} | ||
|
||
// Unlike bytes.Replace it allows you to specify range | ||
func Replace(a []byte, from, to int, new []byte) []byte { | ||
lenDiff := len(new) - (to - from) | ||
|
||
if lenDiff > 0 { | ||
// Extend if new segment bigger | ||
a = append(a, make([]byte, lenDiff)...) | ||
copy(a[to+lenDiff:], a[to:]) | ||
copy(a[from:from+len(new)], new) | ||
|
||
return a | ||
} else if lenDiff < 0 { | ||
copy(a[from:], new) | ||
copy(a[from+len(new):],a[to:]) | ||
return a[:len(a) + lenDiff] | ||
} else { // same size | ||
copy(a[from:], new) | ||
return a | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package byteutils | ||
|
||
import ( | ||
"testing" | ||
"bytes" | ||
) | ||
|
||
func TestCut(t *testing.T) { | ||
if !bytes.Equal(Cut([]byte("123456"), 2, 4), []byte("1256")) { | ||
t.Error("Should properly cut") | ||
} | ||
} | ||
|
||
func TestInsert(t *testing.T) { | ||
if !bytes.Equal(Insert([]byte("123456"), 2, []byte("abcd")), []byte("12abcd3456")) { | ||
t.Error("Should insert into middle of slice") | ||
} | ||
} | ||
|
||
func TestReplace(t *testing.T) { | ||
if !bytes.Equal(Replace([]byte("123456"), 2, 4, []byte("ab")), []byte("12ab56")) { | ||
t.Error("Should replace when same length") | ||
} | ||
|
||
if !bytes.Equal(Replace([]byte("123456"), 2, 4, []byte("abcd")), []byte("12abcd56")) { | ||
t.Error("Should replace when replacement length bigger") | ||
} | ||
|
||
if !bytes.Equal(Replace([]byte("123456"), 2, 5, []byte("ab")), []byte("12ab6")) { | ||
t.Error("Should replace when replacement length bigger") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.