Source File
clone.go
Belonging Package
net/http
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http
import (
_ // for linkname
)
// cloneURLValues should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneURLValues
func cloneURLValues( url.Values) url.Values {
if == nil {
return nil
}
// http.Header and url.Values have the same representation, so temporarily
// treat it like http.Header, which does have a clone:
return url.Values(Header().Clone())
}
// cloneURL should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneURL
func cloneURL( *url.URL) *url.URL {
if == nil {
return nil
}
:= new(url.URL)
* = *
if .User != nil {
.User = new(url.Userinfo)
*.User = *.User
}
return
}
// cloneMultipartForm should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneMultipartForm
func cloneMultipartForm( *multipart.Form) *multipart.Form {
if == nil {
return nil
}
:= &multipart.Form{
Value: (map[string][]string)(Header(.Value).Clone()),
}
if .File != nil {
:= make(map[string][]*multipart.FileHeader)
for , := range .File {
:= make([]*multipart.FileHeader, len())
for , := range {
[] = cloneMultipartFileHeader()
}
[] =
}
.File =
}
return
}
// cloneMultipartFileHeader should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneMultipartFileHeader
func cloneMultipartFileHeader( *multipart.FileHeader) *multipart.FileHeader {
if == nil {
return nil
}
:= new(multipart.FileHeader)
* = *
.Header = textproto.MIMEHeader(Header(.Header).Clone())
return
}
// cloneOrMakeHeader invokes Header.Clone but if the
// result is nil, it'll instead make and return a non-nil Header.
//
// cloneOrMakeHeader should be an internal detail,
// but widely used packages access it using linkname.
// Notable members of the hall of shame include:
// - github.com/searKing/golang
//
// Do not remove or change the type signature.
// See go.dev/issue/67401.
//
//go:linkname cloneOrMakeHeader
func cloneOrMakeHeader( Header) Header {
:= .Clone()
if == nil {
= make(Header)
}
return
}
The pages are generated with Golds v0.6.9-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |