type fileTransport … // NewFileTransport returns a new [RoundTripper], serving the provided // [FileSystem]. The returned RoundTripper ignores the URL host in its // incoming requests, as well as most other properties of the // request. // // The typical use case for NewFileTransport is to register the "file" // protocol with a [Transport], as in: // // t := &http.Transport{} // t.RegisterProtocol("file", http.NewFileTransport(http.Dir("/"))) // c := &http.Client{Transport: t} // res, err := c.Get("file:///etc/passwd") // ... func NewFileTransport(fs FileSystem) RoundTripper { … } // NewFileTransportFS returns a new [RoundTripper], serving the provided // file system fsys. The returned RoundTripper ignores the URL host in its // incoming requests, as well as most other properties of the // request. The files provided by fsys must implement [io.Seeker]. // // The typical use case for NewFileTransportFS is to register the "file" // protocol with a [Transport], as in: // // fsys := os.DirFS("/") // t := &http.Transport{} // t.RegisterProtocol("file", http.NewFileTransportFS(fsys)) // c := &http.Client{Transport: t} // res, err := c.Get("file:///etc/passwd") // ... func NewFileTransportFS(fsys fs.FS) RoundTripper { … } func (t fileTransport) RoundTrip(req *Request) (resp *Response, err error) { … } func newPopulateResponseWriter() (*populateResponse, <-chan *Response) { … } type populateResponse … func (pr *populateResponse) finish() { … } func (pr *populateResponse) sendResponse() { … } func (pr *populateResponse) Header() Header { … } func (pr *populateResponse) WriteHeader(code int) { … } func (pr *populateResponse) Write(p []byte) (n int, err error) { … }