Skip to content

File download is skipped when headResp.ContentLength is 0 #538

@martijnvdp

Description

@martijnvdp

HTTP File download is skipped when headResp.ContentLength returns 0

when we access our private terraform module registry hosted on a gitlab deployment behind an entra application proxy the header response returns a contentlength of 0 and than we get an empty archive file (tgz) with terraform that is using go-getter to download the terraform modules.
and get the error from terraform/go-getter:
Error opening a gzip reader for C:\...\..\AppData\Local\Temp\getter1099997155\archive: EOF
like mentioned here #537

After investigation we see that the entra application proxy returns a content length of 0 and when doing it from our on prem environment without the proxy in between we do get a content length greater than zero and the file got correctly downloaded
looks like the azure application proxy is setting the content length to 0

its fixed for us when changing the contentlenght condition to > 0

if headResp.Header.Get("Accept-Ranges") == "bytes" && headResp.ContentLength >= 0 {

like this

if headResp.Header.Get("Accept-Ranges") == "bytes" && headResp.ContentLength > 0 {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions