Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-use http.Request #42

Merged
merged 8 commits into from
Jun 17, 2020
Merged

Conversation

groovili
Copy link
Contributor

Hi!
I've added small optimization and modules support.
The main idea is to re-use http.Request created from params or provided directly and re-create only request.Body from originalBody for retries.
This change simplifies flow.
Also I've changed PostForm because it's mostly the same as Post and can be handled with input params without additional logic.
Tests are passing and no breaking changes.

@sethgrid
Copy link
Owner

@groovili Thanks for making a PR! Looks like there are merge conflicts that need to be resolved first.

@groovili
Copy link
Contributor Author

@sethgrid resolved :)

@sethgrid
Copy link
Owner

@groovili

$ go test
# github.com/sethgrid/pester [github.com/sethgrid/pester.test]
./pester.go:27:64: newline in string
FAIL	github.com/sethgrid/pester [build failed]

Looks like a missing end-quote.

After I added the missing end-quote:

$ go test
--- FAIL: TestCookiesJarPersistence (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x12bb433]

goroutine 44 [running]:
testing.tRunner.func1.1(0x130bce0, 0x15f1420)
	/usr/local/go/src/testing/testing.go:941 +0x3d0
testing.tRunner.func1(0xc000106b40)
	/usr/local/go/src/testing/testing.go:944 +0x3f9
panic(0x130bce0, 0x15f1420)
	/usr/local/go/src/runtime/panic.go:967 +0x15d
github.com/sethgrid/pester.(*Client).pester(0xc00013e000, 0x136a751, 0x3, 0x136a74e, 0x3, 0x0, 0xc000136040, 0x16, 0x0, 0x0, ...)
	/Users/sethammons/workspace/go/src/github.com/sethgrid/pester/pester.go:346 +0x4c3
github.com/sethgrid/pester.(*Client).Get(...)
	/Users/sethammons/workspace/go/src/github.com/sethgrid/pester/pester.go:436
github.com/sethgrid/pester.TestCookiesJarPersistence(0xc000106b40)
	/Users/sethammons/workspace/go/src/github.com/sethgrid/pester/pester_test.go:580 +0x352
testing.tRunner(0xc000106b40, 0x13841b8)
	/usr/local/go/src/testing/testing.go:992 +0xdc
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1043 +0x357
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x124df4e]

goroutine 47 [running]:
net/http.(*Client).do(0xc00012e120, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/http/client.go:576 +0xae
net/http.(*Client).Do(...)
	/usr/local/go/src/net/http/client.go:567
github.com/sethgrid/pester.(*Client).pester.func2(0xc00013e000, 0xc0001120b0, 0xc0001120c0, 0xc000104900, 0xc00012e120, 0xc0001048a0, 0x136a751, 0x3, 0x136a74e, 0x3, ...)
	/Users/sethammons/workspace/go/src/github.com/sethgrid/pester/pester.go:298 +0x1c2
created by github.com/sethgrid/pester.(*Client).pester
	/Users/sethammons/workspace/go/src/github.com/sethgrid/pester/pester.go:284 +0x4bb
exit status 2
FAIL	github.com/sethgrid/pester	0.053s

Looks like there is still some work to be done.

@groovili
Copy link
Contributor Author

@sethgrid Sorry, my bad. Did small change after checking tests.
It should be ok now.

@groovili groovili requested a review from sethgrid June 17, 2020 17:18
@sethgrid sethgrid merged commit d2ad9ec into sethgrid:master Jun 17, 2020
@sethgrid
Copy link
Owner

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants