header.go 806 B

1234567891011121314151617181920212223242526272829303132
  1. package connection
  2. import (
  3. "fmt"
  4. "net/http"
  5. "github.com/cloudflare/cloudflared/h2mux"
  6. )
  7. const (
  8. ResponseMetaHeaderField = "cf-cloudflared-response-meta"
  9. )
  10. var (
  11. canonicalResponseUserHeadersField = http.CanonicalHeaderKey(h2mux.ResponseUserHeadersField)
  12. canonicalResponseMetaHeaderField = http.CanonicalHeaderKey(ResponseMetaHeaderField)
  13. responseMetaHeaderCfd = mustInitRespMetaHeader("cloudflared")
  14. responseMetaHeaderOrigin = mustInitRespMetaHeader("origin")
  15. )
  16. type responseMetaHeader struct {
  17. Source string `json:"src"`
  18. }
  19. func mustInitRespMetaHeader(src string) string {
  20. header, err := json.Marshal(responseMetaHeader{Source: src})
  21. if err != nil {
  22. panic(fmt.Sprintf("Failed to serialize response meta header = %s, err: %v", src, err))
  23. }
  24. return string(header)
  25. }