X7ROOT File Manager
Current Path:
/opt/golang/1.22.0/src/net/http
opt
/
golang
/
1.22.0
/
src
/
net
/
http
/
📁
..
📄
alpn_test.go
(3.01 KB)
📁
cgi
📄
client.go
(33.4 KB)
📄
client_test.go
(63.24 KB)
📄
clientserver_test.go
(46.07 KB)
📄
clone.go
(1.56 KB)
📄
cookie.go
(11.53 KB)
📄
cookie_test.go
(19.26 KB)
📁
cookiejar
📄
doc.go
(3.42 KB)
📄
example_filesystem_test.go
(2.04 KB)
📄
example_handle_test.go
(560 B)
📄
example_test.go
(5.38 KB)
📄
export_test.go
(8.43 KB)
📁
fcgi
📄
filetransport.go
(3.52 KB)
📄
filetransport_test.go
(2.62 KB)
📄
fs.go
(30.36 KB)
📄
fs_test.go
(46.7 KB)
📄
h2_bundle.go
(357.28 KB)
📄
h2_error.go
(812 B)
📄
h2_error_test.go
(1.04 KB)
📄
header.go
(7.9 KB)
📄
header_test.go
(6.05 KB)
📄
http.go
(5.13 KB)
📄
http_test.go
(5.22 KB)
📁
httptest
📁
httptrace
📁
httputil
📁
internal
📄
jar.go
(900 B)
📄
main_test.go
(4.94 KB)
📄
mapping.go
(1.68 KB)
📄
mapping_test.go
(2.95 KB)
📄
method.go
(517 B)
📄
omithttp2.go
(1.91 KB)
📄
pattern.go
(15.17 KB)
📄
pattern_test.go
(14.5 KB)
📁
pprof
📄
proxy_test.go
(1.16 KB)
📄
range_test.go
(2.38 KB)
📄
readrequest_test.go
(9.7 KB)
📄
request.go
(48.34 KB)
📄
request_test.go
(42.39 KB)
📄
requestwrite_test.go
(23.3 KB)
📄
response.go
(11.1 KB)
📄
response_test.go
(23.63 KB)
📄
responsecontroller.go
(4.17 KB)
📄
responsecontroller_test.go
(9.81 KB)
📄
responsewrite_test.go
(6.89 KB)
📄
roundtrip.go
(566 B)
📄
roundtrip_js.go
(11.8 KB)
📄
routing_index.go
(3.95 KB)
📄
routing_index_test.go
(4.02 KB)
📄
routing_tree.go
(7.48 KB)
📄
routing_tree_test.go
(6.89 KB)
📄
serve_test.go
(192.54 KB)
📄
servemux121.go
(5.6 KB)
📄
server.go
(120.67 KB)
📄
server_test.go
(6.95 KB)
📄
sniff.go
(7.9 KB)
📄
sniff_test.go
(9.56 KB)
📄
socks_bundle.go
(12.9 KB)
📄
status.go
(7.45 KB)
📁
testdata
📄
transfer.go
(30.89 KB)
📄
transfer_test.go
(9.13 KB)
📄
transport.go
(87.81 KB)
📄
transport_default_other.go
(362 B)
📄
transport_default_wasm.go
(364 B)
📄
transport_internal_test.go
(6.05 KB)
📄
transport_test.go
(186.06 KB)
📄
triv.go
(3.22 KB)
Editing: routing_index.go
// Copyright 2023 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 "math" // A routingIndex optimizes conflict detection by indexing patterns. // // The basic idea is to rule out patterns that cannot conflict with a given // pattern because they have a different literal in a corresponding segment. // See the comments in [routingIndex.possiblyConflictingPatterns] for more details. type routingIndex struct { // map from a particular segment position and value to all registered patterns // with that value in that position. // For example, the key {1, "b"} would hold the patterns "/a/b" and "/a/b/c" // but not "/a", "b/a", "/a/c" or "/a/{x}". segments map[routingIndexKey][]*pattern // All patterns that end in a multi wildcard (including trailing slash). // We do not try to be clever about indexing multi patterns, because there // are unlikely to be many of them. multis []*pattern } type routingIndexKey struct { pos int // 0-based segment position s string // literal, or empty for wildcard } func (idx *routingIndex) addPattern(pat *pattern) { if pat.lastSegment().multi { idx.multis = append(idx.multis, pat) } else { if idx.segments == nil { idx.segments = map[routingIndexKey][]*pattern{} } for pos, seg := range pat.segments { key := routingIndexKey{pos: pos, s: ""} if !seg.wild { key.s = seg.s } idx.segments[key] = append(idx.segments[key], pat) } } } // possiblyConflictingPatterns calls f on all patterns that might conflict with // pat. If f returns a non-nil error, possiblyConflictingPatterns returns immediately // with that error. // // To be correct, possiblyConflictingPatterns must include all patterns that // might conflict. But it may also include patterns that cannot conflict. // For instance, an implementation that returns all registered patterns is correct. // We use this fact throughout, simplifying the implementation by returning more // patterns that we might need to. func (idx *routingIndex) possiblyConflictingPatterns(pat *pattern, f func(*pattern) error) (err error) { // Terminology: // dollar pattern: one ending in "{$}" // multi pattern: one ending in a trailing slash or "{x...}" wildcard // ordinary pattern: neither of the above // apply f to all the pats, stopping on error. apply := func(pats []*pattern) error { if err != nil { return err } for _, p := range pats { err = f(p) if err != nil { return err } } return nil } // Our simple indexing scheme doesn't try to prune multi patterns; assume // any of them can match the argument. if err := apply(idx.multis); err != nil { return err } if pat.lastSegment().s == "/" { // All paths that a dollar pattern matches end in a slash; no paths that // an ordinary pattern matches do. So only other dollar or multi // patterns can conflict with a dollar pattern. Furthermore, conflicting // dollar patterns must have the {$} in the same position. return apply(idx.segments[routingIndexKey{s: "/", pos: len(pat.segments) - 1}]) } // For ordinary and multi patterns, the only conflicts can be with a multi, // or a pattern that has the same literal or a wildcard at some literal // position. // We could intersect all the possible matches at each position, but we // do something simpler: we find the position with the fewest patterns. var lmin, wmin []*pattern min := math.MaxInt hasLit := false for i, seg := range pat.segments { if seg.multi { break } if !seg.wild { hasLit = true lpats := idx.segments[routingIndexKey{s: seg.s, pos: i}] wpats := idx.segments[routingIndexKey{s: "", pos: i}] if sum := len(lpats) + len(wpats); sum < min { lmin = lpats wmin = wpats min = sum } } } if hasLit { apply(lmin) apply(wmin) return err } // This pattern is all wildcards. // Check it against everything. for _, pats := range idx.segments { apply(pats) } return err }
Upload File
Create Folder