MCPcopy
hub / github.com/caddyserver/caddy / Provision

Method Provision

modules/caddyhttp/reverseproxy/httptransport.go:182–202  ·  view source on GitHub ↗

Provision sets up h.Transport with a *http.Transport that is ready to use.

(ctx caddy.Context)

Source from the content-addressed store, hash-verified

180// Provision sets up h.Transport with a *http.Transport
181// that is ready to use.
182func (h *HTTPTransport) Provision(ctx caddy.Context) error {
183 if len(h.Versions) == 0 {
184 h.Versions = []string{"1.1", "2"}
185 }
186 // some users may provide http versions not recognized by caddy, instead of trying to
187 // guess the version, we just error out and let the user fix their config
188 // see: https://github.com/caddyserver/caddy/issues/7111
189 for _, v := range h.Versions {
190 if !slices.Contains(allowedVersions, v) {
191 return fmt.Errorf("unsupported HTTP version: %s, supported version: %s", v, allowedVersionsString)
192 }
193 }
194
195 rt, err := h.NewTransport(ctx)
196 if err != nil {
197 return err
198 }
199 h.Transport = rt
200
201 return nil
202}
203
204// NewTransport builds a standard-lib-compatible http.Transport value from h.
205func (h *HTTPTransport) NewTransport(caddyCtx caddy.Context) (*http.Transport, error) {

Callers 1

ProvisionMethod · 0.95

Calls 1

NewTransportMethod · 0.95

Tested by

no test coverage detected