Skip to content

How to get Content-Length header without downloading the resource? #565

Closed Answered by jeevatkm
enricorotundo asked this question in Q&A
Discussion options

You must be logged in to vote

@enricorotundo I'm sorry for the delay. You could do -

client := resty.New()
rsp, err := client.R().EnableTrace().Head("https://gist.githubusercontent.com/enricorotundo/990f0ad01a50d08dfb580e4ad404870e/raw/aa6934257351a0da93f1e740c72f27128590cebc/foo_data.txt")
fmt.Println(err)
fmt.Println(rsp.Header().Get("Content-Length"))

Output:

574

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jeevatkm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants