config_go124.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2024 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build go1.24
  5. package http2
  6. import "net/http"
  7. // fillNetHTTPServerConfig sets fields in conf from srv.HTTP2.
  8. func fillNetHTTPServerConfig(conf *http2Config, srv *http.Server) {
  9. fillNetHTTPConfig(conf, srv.HTTP2)
  10. }
  11. // fillNetHTTPTransportConfig sets fields in conf from tr.HTTP2.
  12. func fillNetHTTPTransportConfig(conf *http2Config, tr *http.Transport) {
  13. fillNetHTTPConfig(conf, tr.HTTP2)
  14. }
  15. func fillNetHTTPConfig(conf *http2Config, h2 *http.HTTP2Config) {
  16. if h2 == nil {
  17. return
  18. }
  19. if h2.MaxConcurrentStreams != 0 {
  20. conf.MaxConcurrentStreams = uint32(h2.MaxConcurrentStreams)
  21. }
  22. if h2.MaxEncoderHeaderTableSize != 0 {
  23. conf.MaxEncoderHeaderTableSize = uint32(h2.MaxEncoderHeaderTableSize)
  24. }
  25. if h2.MaxDecoderHeaderTableSize != 0 {
  26. conf.MaxDecoderHeaderTableSize = uint32(h2.MaxDecoderHeaderTableSize)
  27. }
  28. if h2.MaxConcurrentStreams != 0 {
  29. conf.MaxConcurrentStreams = uint32(h2.MaxConcurrentStreams)
  30. }
  31. if h2.MaxReadFrameSize != 0 {
  32. conf.MaxReadFrameSize = uint32(h2.MaxReadFrameSize)
  33. }
  34. if h2.MaxReceiveBufferPerConnection != 0 {
  35. conf.MaxUploadBufferPerConnection = int32(h2.MaxReceiveBufferPerConnection)
  36. }
  37. if h2.MaxReceiveBufferPerStream != 0 {
  38. conf.MaxUploadBufferPerStream = int32(h2.MaxReceiveBufferPerStream)
  39. }
  40. if h2.SendPingTimeout != 0 {
  41. conf.SendPingTimeout = h2.SendPingTimeout
  42. }
  43. if h2.PingTimeout != 0 {
  44. conf.PingTimeout = h2.PingTimeout
  45. }
  46. if h2.WriteByteTimeout != 0 {
  47. conf.WriteByteTimeout = h2.WriteByteTimeout
  48. }
  49. if h2.PermitProhibitedCipherSuites {
  50. conf.PermitProhibitedCipherSuites = true
  51. }
  52. if h2.CountError != nil {
  53. conf.CountError = h2.CountError
  54. }
  55. }