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

Allow extra headers of HEAD request for container/object requests. #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

charz
Copy link
Contributor

@charz charz commented Sep 13, 2022

Hi team,

I'd like to add headers support for HEAD requests that might help in some case like X-Newest: true (#100) or some custom headers.

Thanks!

@charz
Copy link
Contributor Author

charz commented Sep 13, 2022

I'm not sure why go1.17 failed in below,

  Running [/home/runner/golangci-lint-1.49.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
  Error: File is not `goimports`-ed (goimports)
  Error: File is not `goimports`-ed (goimports)
  Error: File is not `goimports`-ed (goimports)
  Error: File is not `goimports`-ed (goimports)
  Error: File is not `goimports`-ed (goimports)
  Error: File is not `goimports`-ed (goimports)

I tried to run golangci-lint looks fine in my end.

➜  charz_ncw_swift git:(add_headers_for_HEAD_container_object) ~/go/bin/golangci-lint run --fix                                         
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused. 
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused. 
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused. 

➜  charz_ncw_swift git:(add_headers_for_HEAD_container_object) go version
go version go1.18.3 darwin/arm64

Copy link
Owner

@ncw ncw left a comment

Choose a reason for hiding this comment

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

This breaks backwards compatibility, so you'll need to introduce a new ContainerHeaders function or similar

@charz
Copy link
Contributor Author

charz commented Sep 26, 2022

Just add two extraheaders for container and object in connection structure. Do you think that make sense?

@ncw
Copy link
Owner

ncw commented Sep 27, 2022

I'd prefer new functions with extra parameters otherwise you create a global state which will be difficult to share between threads.

@charz
Copy link
Contributor Author

charz commented Sep 28, 2022

I'd prefer new functions with extra parameters otherwise you create a global state which will be difficult to share between threads.

Do you mean something likes this?

func (c *Connection) ContainerWithHeaders(ctx context.Context, container string, h Headers) (info Container, headers Headers, err error) 
func (c *Connection) ObjectWithHeaders(ctx context.Context, container string, objectName string, h Headers) (info Object, headers Headers, err error)

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