-
Notifications
You must be signed in to change notification settings - Fork 184
Add SetHeader method to Klaytn client #1020
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks good to me
networks/rpc/http.go
Outdated
@@ -48,9 +49,12 @@ var nullAddr, _ = net.ResolveTCPAddr("tcp", "127.0.0.1:0") | |||
|
|||
type httpConn struct { | |||
client *http.Client | |||
url string | |||
req *http.Request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
req *http.Request |
Is this 'req' field needed?
Ethereum also removed this field by adding the SetHeader method.
And all unit tests in the rpc directory pass even without this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake. Thank you for leting me know!
networks/rpc/http.go
Outdated
req *http.Request | ||
closeOnce sync.Once | ||
closed chan struct{} | ||
mu sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mu sync.Mutex | |
mu sync.Mutex // protects headers |
It might be useful for later to write down the use of the mutex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the comment. Thanks!
Proposed changes
This change adds
SetHeader
method to Klaytn client.With this change, KAS or Infura users which need HTTP Header configuration for credentials can use Klaytn client also.
Most of this change is imported from ethereum/go-ethereum#21392
Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
$ make test
)