aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/pattern.go
AgeCommit message (Collapse)Author
2025-11-13net/http: remove unused isLitOrSingle and isNotToken1911860538
isLitOrSingle and isNotToken are private and unused. Change-Id: I07718d4496e92d5f75ed74986e174a8aa1f70a88 GitHub-Last-Rev: 722c4dccd85dca5d28a52e95a4f9efbab2b11807 GitHub-Pull-Request: golang/go#76216 Reviewed-on: https://go-review.googlesource.com/c/go/+/718700 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-26net/http: allow multiple spaces between method and path in mux patternsJes Cok
Fixes #64910 Change-Id: I14fd1e35c95b14591e3ad7b889dc1ab19a008730 GitHub-Last-Rev: b8d436cdee93d103703e7e6d4bb28315c5035300 GitHub-Pull-Request: golang/go#65868 Reviewed-on: https://go-review.googlesource.com/c/go/+/565916 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-09-25net/http: remove unused functionJonathan Amsterdam
Change-Id: I4364d94663282249e632d12026a810147844ad2e Reviewed-on: https://go-review.googlesource.com/c/go/+/530615 Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2023-09-25net/http: unescape paths and patterns by segmentJonathan Amsterdam
When parsing patterns and matching, split the path into segments at slashes, then unescape each segment. This behaves as most people would expect: - The pattern "/%61" matches the paths "/a" and "/%61". - The pattern "/%7B" matches the path "/{". (If we did not unescape patterns, there would be no way to write that pattern: because "/{" is a parse error because it is an invalid wildcard.) - The pattern "/user/{u}" matches "/user/john%2Fdoe" with u set to "john/doe". - The unexpected redirections of #21955 will not occur. A later CL will restore the old behavior behind a GODEBUG setting. Updates #61410. Fixes #21955. Change-Id: I99025e149021fc94bf87d351699270460db532d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/530575 Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2023-09-19net/http: show offset in pattern parsing errorJonathan Amsterdam
Track the offset in the pattern string being parsed so we can show it in the error message. Change-Id: I495b99378d866f359f45974ffc33587e2c1e366d Reviewed-on: https://go-review.googlesource.com/c/go/+/529123 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-19net/http: explain why two patterns conflictJonathan Amsterdam
It can be difficult to tell at a glance why two patterns conflict, so explain it with example paths. Change-Id: Ie384f0a4ef64f30e6e6898bce4b88027bc81034b Reviewed-on: https://go-review.googlesource.com/c/go/+/529122 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-18net/http: fix bugs in comparePaths and combineRelationshipsJonathan Amsterdam
combineRelationships was wrong on one case: if one part of a pattern overlaps and the other is disjoint, the result is disjoint, not overlaps. For example: /a/{x}/c /{x}/b/d Here the prefix consisting of the first two segments overlaps, but the third segments are disjoint. The patterns as a whole are disjoint. comparePaths was wrong in a couple of ways: First, the loop shouldn't exit early when it sees an overlap, for the reason above: later information may change that. Once the loop was allowed to continue, we had to handle the "overlaps" case at the end. The insight there, which generalized the existing code, is that if the shorter path ends in a multi, that multi matches the remainder of the longer path and more. (It must be "and more": the longer path has at least two segments, so it couldn't match one segment while the shorter path's multi can.) That means we can treat the result as the combination moreGeneral and the relationship of the common prefix. Change-Id: I11dab2c020d820730fb38296d9d6b072bd2a5350 Reviewed-on: https://go-review.googlesource.com/c/go/+/529119 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-12net/http: pattern.conflictsWithJonathan Amsterdam
Add the conflictsWith method, which determines whether two patterns conflict with each other. Updates #61410. Change-Id: Id4f9a471dc9d0420d927a68d2864128a096b74f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/526616 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-11net/http: extended routing patternsJonathan Amsterdam
This is the first of several CLs implementing the proposal for enhanced ServeMux routing, https://go.dev/issue/61410. Define a type to represent extended routing patterns and a function to parse a string into one. Updates #61410. Change-Id: I779689acf1f14b20d12c9264251f7dc002b68c49 Reviewed-on: https://go-review.googlesource.com/c/go/+/526815 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Eli Bendersky <eliben@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>