1

I'm trying to deploy a service that sets very long headers in some cases. When running locally, I am able to successfully set and receive long (>8KB) headers without issue. However, after deploying to cloud run, there is a point where these long headers are getting stripped completely.

It's possible that it's some other issue with my application behaving differently in the two environments, but is there a maximum header length specified by Google Cloud Run or any info at all about the requirements/limitations for setting HTTP headers?

7
  • What HTTP server are you using here? Is it gunicorn? Aug 14, 2019 at 19:44
  • @DustinIngram I'm using the webserver built into the go standard library. However, that isn't the issue since when I run it locally, even from within Docker, the headers flow through without issue. Long headers are only stripped out when I run it inside of cloud run.
    – Ameo
    Aug 14, 2019 at 21:27
  • Thanks. Can you include a small example app & Dockerfile I could test with? Aug 14, 2019 at 22:08
  • @DustinIngram Here: gist.github.com/Ameobea/aa67dfe5c6e2167a8fef9afda3f27b0b I've run that container locally and can verify that the 10k character header is successfully received by my HTTP client. I also deployed it to cloud run: cloud-run-header-limit-demo-mi7imxlw6a-uc.a.run.app If you make a request to that service, you'll see that the header is stripped off.
    – Ameo
    Aug 15, 2019 at 0:20
  • According to golang.org/pkg/net/http/#pkg-constants DefaultMaxHeaderBytes is 1MB which would be about 10K characters. You may wan to try setting Server.MaxHeaderBytes to a higher value and see if your headers come through. Aug 15, 2019 at 3:53

1 Answer 1

3

It appears that any header with a total length greater than 8190 characters (including name, colon and value) will be stripped.

This should be included at https://cloud.google.com/run/quotas. I've filed an issue internally to resolve this.

1
  • 4
    I'd assume there's probably an undocumented upper-limit that's enforced regardless of the language by Google Cloud’s traffic proxy serving Cloud Run apps. Aug 14, 2019 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.