Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Add SetHeader method to Klaytn client #1020

Merged
merged 2 commits into from
Sep 9, 2021

Conversation

aidan-kwon
Copy link
Member

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.

  • Bugfix
  • New feature or enhancement
  • Others

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.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

yoomee1313
yoomee1313 previously approved these changes Aug 5, 2021
Copy link
Contributor

@yoomee1313 yoomee1313 left a 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

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member Author

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!

req *http.Request
closeOnce sync.Once
closed chan struct{}
mu sync.Mutex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mu sync.Mutex
mu sync.Mutex // protects headers

It might be useful for later to write down the use of the mutex.

Copy link
Member Author

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!

@aidan-kwon aidan-kwon merged commit 75567f3 into klaytn:dev Sep 9, 2021
@aidan-kwon aidan-kwon deleted the 210804-clientSetHeader branch September 9, 2021 00:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants