Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync fork with upstream #67

Merged
merged 94 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
2dc6eb6
net/http: declare publicErr as a constant
callthingsoff Jun 20, 2023
7c6c2e4
Revert "net/http: use Copy in ServeContent if CopyN not needed"
neild Jul 24, 2023
e7c7b52
all: use built-in clear to clear maps
callthingsoff Jul 25, 2023
581f239
net/http: perform streaming body feature detection once per process
dmitshur Jul 23, 2023
6374140
net/http: fix doc comment on FormValue function
eduardbme Jul 26, 2023
4ed3564
all: add a few more godoc links
mvdan Jul 7, 2023
deb5e09
net/http: add ServeFileFS, FileServerFS, NewFileTransportFS
mauri870 Jul 31, 2023
141a4ea
net/http: permit requests with invalid Host headers
neild Jul 19, 2023
84f051d
net/http: sanitize User-Agent header in request writer
neild Aug 7, 2023
69be2a3
all: update vendored dependencies
mknyszek Aug 9, 2023
12502c9
net/http: disallow empty Content-Length header
mauri870 Aug 10, 2023
d7220b1
net/http: use cancelKey to cancel request
AlexanderYastrebov Aug 2, 2023
8dfaa07
net/http: clear reference to the request context after transport getConn
AlexanderYastrebov Jul 25, 2023
31f798d
net/http: use testenv.Command instead of exec.Command in tests
Aug 22, 2023
2efe866
net/http: fix request canceler leak on connection close
AlexanderYastrebov Aug 22, 2023
187b028
net/http: revert fix request canceler leak on connection close
AlexanderYastrebov Aug 23, 2023
2f21b7c
net/http: remove arbitrary timeout from TestTransportGCRequest
neild Aug 24, 2023
286b3c1
net/http: use reflect.TypeFor for known types
ianlancetaylor Aug 23, 2023
052b7a7
net/http: deflake TestRequestBodyLimit
neild Aug 24, 2023
472d9b6
net/http: document when request bodies are closed in more places
neild Aug 24, 2023
3c38887
net/http/cgi: workaround for closure inlining issue
mdempsky Aug 25, 2023
9dc6fbc
Revert "net/http/cgi: workaround for closure inlining issue"
cuonglm Aug 26, 2023
b6432a7
net/http: document setting of Proxy-Authorization header
neild Jul 24, 2023
891480f
net/http: revert "support streaming POST content in wasm"
haruyama480 Aug 25, 2023
dbf1c18
all: use ^TestName$ regular pattern for invoking a single test
dmitshur Sep 3, 2023
22c22d1
all: use ^$ instead of XXXX, NoSuchTestExists to match no tests
dmitshur Sep 3, 2023
f975438
net/http: extended routing patterns
jba Sep 8, 2023
073eae9
net/http: pattern.conflictsWith
jba Sep 8, 2023
bb0da64
net/http: mapping data structure
jba Sep 11, 2023
0d0a3ef
net/http: routing tree
jba Sep 11, 2023
6097cd8
net/http: use new Go Doc list syntax
abhinav Sep 13, 2023
dc55a0e
net/http: ServeMux handles extended patterns
jba Sep 13, 2023
cd9a609
net/http: scale rstAvoidanceDelay to reduce test flakiness
Sep 11, 2023
94c8fbe
net/http: add test for registration errors
jba Sep 13, 2023
90debc4
net/http: give ServeMux.handler a better name
jba Sep 13, 2023
6790ea8
net/http: implement path value methods on Request
jba Sep 13, 2023
62023bc
net/http: synchronize tests that use reqNum counters
Sep 14, 2023
c2c93ec
net/http: handle MethodNotAllowed
jba Sep 15, 2023
ab839be
net/http: avoid leaking goroutines when TestServerGracefulClose retries
Sep 15, 2023
44b3cfb
net/http: fix bugs in comparePaths and combineRelationships
jba Sep 18, 2023
fc45211
net/http: buffer the testConn close channel in TestHandlerFinishSkipB…
Sep 19, 2023
65cb8e5
net/http: index patterns for faster conflict detection
jba Sep 18, 2023
7f22ddf
net/http: explain why two patterns conflict
jba Sep 19, 2023
b520101
net/http: show offset in pattern parsing error
jba Sep 19, 2023
e0f72cc
net/http: test index exhaustively
jba Sep 19, 2023
6207ea6
net/http: add a benchmark for multi indexing
jba Sep 19, 2023
f77dc2c
net/http: eliminate a goroutine leak in (*persistConn.addTLS)
Sep 20, 2023
5211518
net/http: eliminate more clientServerTest leaks in tests that use run…
Sep 20, 2023
1f52f9f
all: simplify bool conditions
alexandear Sep 6, 2023
bac15b0
net/http: unescape paths and patterns by segment
jba Sep 22, 2023
49d52c0
net/http: remove unused function
jba Sep 22, 2023
495a333
net/http: add extra synchronization for a Logf call in TestTransportA…
Sep 26, 2023
0b34f7d
net/http: add GODEBUG setting for old ServeMux behavior
jba Sep 23, 2023
982fb05
net/http: add a test for an empty ServeMux
jba Sep 25, 2023
807697b
net/http: document new ServeMux patterns
jba Sep 25, 2023
d34bfb9
net/http/cgi: set SERVER_PORT to 443 when req.TLS != nil
edef1c Dec 3, 2022
6b77343
net/http: fix ServeMux pattern registration
jba Oct 5, 2023
f75d9bb
all: pull in x/net v0.17.0 and its dependencies
dmitshur Oct 10, 2023
376c7e8
all: drop old +build lines
dmitshur Oct 17, 2023
85f6c0b
all: update vendored dependencies
dmitshur Oct 17, 2023
32d89f5
net/http: remove outdated comment about a support of CONNECT method
KeiichiHirobe Oct 22, 2023
b4d8baa
net/http: pull http2 underflow fix from x/net/http2
mauri870 Oct 26, 2023
c8cdf46
net/http: remove arbitrary timeouts in tests of Server.ErrorLog
Nov 2, 2023
5eaaed6
net/http/httptest: remove unnecessary creation of http.Transport
ZekeLu Nov 1, 2023
dd84204
net/http: set/override Content-Length for encoded range requests
mitar Nov 6, 2023
b8d3b92
net/http: remove Content-Encoding header in roundtrip_js
Sep 21, 2023
fa70e90
net/http/cgi: the PATH_INFO should be empty or start with a slash
aimuz Nov 3, 2023
6359758
net/http/cgi: eliminate use of Perl in tests
aimuz Nov 7, 2023
61e2401
net/http/cookiejar: remove unused variable
wulianglongrd Oct 29, 2023
943f1d8
net/http: use copyBufPool in transferWriter.doBodyCopy()
mmatczuk Nov 9, 2023
0d035c0
crypto/tls: remove RSA KEX ciphers from the default list
rolandshoemaker Nov 10, 2023
5e52645
net/http: don't set length for non-range encoded content requests
neild Nov 15, 2023
abd13dd
net,os: arrange zero-copy of os.File and net.TCPConn to net.UnixConn
panjf2000 Feb 28, 2023
9704e81
all: add missing copyright header
callthingsoff Nov 13, 2023
4efbfb2
src: a/an grammar fixes
scop Nov 18, 2023
4e0c9ea
net/http: use pointers to array for copyBufPool
Jorropo Nov 8, 2023
d90121b
all: update vendored dependencies
dmitshur Nov 29, 2023
f997504
net/http: avoid leaking io.Copy goroutines (and hijacked connections)…
Dec 1, 2023
72e4f41
net/http: limit chunked data overhead
neild Nov 7, 2023
635f30d
internal/profile: fully decode proto even if there are no samples
prattmic Dec 6, 2023
3db8a97
all: remove newline characters after return statements
Dec 7, 2023
7dc0f34
net/http: make Request.Clone create fresh copies for matches and othe…
callthingsoff Jan 3, 2024
b3da930
net/http/cgi: in TestCopyError, check for a Handler.ServeHTTP gorouti…
Jan 4, 2024
760bd31
net/http: respond with 400 Bad Request for empty hex number of chunk …
panjf2000 Jan 4, 2024
d1f9a93
net/http: clarify the precedence order for Request.FormValue
callthingsoff Jan 9, 2024
fedd50f
net: add available godoc link
cuishuang Nov 6, 2023
66b1a31
[release-branch.go1.22] net/http: add missing call to decConnsPerHost
tibbes Feb 14, 2024
1008e41
[release-branch.go1.22] net/http, net/http/cookiejar: avoid subdomain…
neild Jan 11, 2024
8715fee
[release-branch.go1.22] all: update golang.org/x/net
neild Mar 27, 2024
efc54b3
[release-branch.go1.22] net/http: update bundled golang.org/x/net/http2
neild Mar 28, 2024
87b4571
chore: upgrade UPSTREAM to go1.22.2
DecFox Nov 22, 2024
4cc200b
Merge branch 'golang-http-upstream' into merged-main
DecFox Nov 22, 2024
b933b81
chore: sync with upstream
DecFox Nov 24, 2024
9e5eae3
chore: upgrade dependencies
DecFox Nov 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21.8"
go-version: "1.22.2"

- name: Build
run: go build -v ./...
Expand Down
2 changes: 1 addition & 1 deletion UPSTREAM
Original file line number Diff line number Diff line change
@@ -1 +1 @@
go1.21.11
go1.22.2
146 changes: 146 additions & 0 deletions cgi/cgi_main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// 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 cgi

import (
"fmt"
"io"
"os"
"path"
"sort"
"strings"
"time"

http "github.com/ooni/oohttp"
)

func cgiMain() {
switch path.Join(os.Getenv("SCRIPT_NAME"), os.Getenv("PATH_INFO")) {
case "/bar", "/test.cgi", "/myscript/bar", "/test.cgi/extrapath":
testCGI()
return
}
childCGIProcess()
}

// testCGI is a CGI program translated from a Perl program to complete host_test.
// test cases in host_test should be provided by testCGI.
func testCGI() {
req, err := Request()
if err != nil {
panic(err)
}

err = req.ParseForm()
if err != nil {
panic(err)
}

params := req.Form
if params.Get("loc") != "" {
fmt.Printf("Location: %s\r\n\r\n", params.Get("loc"))
return
}

fmt.Printf("Content-Type: text/html\r\n")
fmt.Printf("X-CGI-Pid: %d\r\n", os.Getpid())
fmt.Printf("X-Test-Header: X-Test-Value\r\n")
fmt.Printf("\r\n")

if params.Get("writestderr") != "" {
fmt.Fprintf(os.Stderr, "Hello, stderr!\n")
}

if params.Get("bigresponse") != "" {
// 17 MB, for OS X: golang.org/issue/4958
line := strings.Repeat("A", 1024)
for i := 0; i < 17*1024; i++ {
fmt.Printf("%s\r\n", line)
}
return
}

fmt.Printf("test=Hello CGI\r\n")

keys := make([]string, 0, len(params))
for k := range params {
keys = append(keys, k)
}
sort.Strings(keys)
for _, key := range keys {
fmt.Printf("param-%s=%s\r\n", key, params.Get(key))
}

envs := envMap(os.Environ())
keys = make([]string, 0, len(envs))
for k := range envs {
keys = append(keys, k)
}
sort.Strings(keys)
for _, key := range keys {
fmt.Printf("env-%s=%s\r\n", key, envs[key])
}

cwd, _ := os.Getwd()
fmt.Printf("cwd=%s\r\n", cwd)
}

type neverEnding byte

func (b neverEnding) Read(p []byte) (n int, err error) {
for i := range p {
p[i] = byte(b)
}
return len(p), nil
}

// childCGIProcess is used by integration_test to complete unit tests.
func childCGIProcess() {
if os.Getenv("REQUEST_METHOD") == "" {
// Not in a CGI environment; skipping test.
return
}
switch os.Getenv("REQUEST_URI") {
case "/immediate-disconnect":
os.Exit(0)
case "/no-content-type":
fmt.Printf("Content-Length: 6\n\nHello\n")
os.Exit(0)
case "/empty-headers":
fmt.Printf("\nHello")
os.Exit(0)
}
Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if req.FormValue("nil-request-body") == "1" {
fmt.Fprintf(rw, "nil-request-body=%v\n", req.Body == nil)
return
}
rw.Header().Set("X-Test-Header", "X-Test-Value")
req.ParseForm()
if req.FormValue("no-body") == "1" {
return
}
if eb, ok := req.Form["exact-body"]; ok {
io.WriteString(rw, eb[0])
return
}
if req.FormValue("write-forever") == "1" {
io.Copy(rw, neverEnding('a'))
for {
time.Sleep(5 * time.Second) // hang forever, until killed
}
}
fmt.Fprintf(rw, "test=Hello CGI-in-CGI\n")
for k, vv := range req.Form {
for _, v := range vv {
fmt.Fprintf(rw, "param-%s=%s\n", k, v)
}
}
for _, kv := range os.Environ() {
fmt.Fprintf(rw, "env-%s\n", kv)
}
}))
os.Exit(0)
}
6 changes: 3 additions & 3 deletions cgi/child.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func envMap(env []string) map[string]string {
return m
}

// RequestFromMap creates an http.Request from CGI variables.
// RequestFromMap creates an [http.Request] from CGI variables.
// The returned Request's Body field is not populated.
func RequestFromMap(params map[string]string) (*http.Request, error) {
r := new(http.Request)
Expand Down Expand Up @@ -139,10 +139,10 @@ func RequestFromMap(params map[string]string) (*http.Request, error) {
return r, nil
}

// Serve executes the provided Handler on the currently active CGI
// Serve executes the provided [Handler] on the currently active CGI
// request, if any. If there's no current CGI environment
// an error is returned. The provided handler may be nil to use
// http.DefaultServeMux.
// [http.DefaultServeMux].
func Serve(handler http.Handler) error {
req, err := Request()
if err != nil {
Expand Down
14 changes: 5 additions & 9 deletions cgi/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,19 @@ func removeLeadingDuplicates(env []string) (ret []string) {
}

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
root := h.Root
if root == "" {
root = "/"
}

if len(req.TransferEncoding) > 0 && req.TransferEncoding[0] == "chunked" {
rw.WriteHeader(http.StatusBadRequest)
rw.Write([]byte("Chunked request bodies are not supported by CGI."))
return
}

pathInfo := req.URL.Path
if root != "/" && strings.HasPrefix(pathInfo, root) {
pathInfo = pathInfo[len(root):]
}
root := strings.TrimRight(h.Root, "/")
pathInfo := strings.TrimPrefix(req.URL.Path, root)

port := "80"
if req.TLS != nil {
port = "443"
}
if matches := trailingPort.FindStringSubmatch(req.Host); len(matches) != 0 {
port = matches[1]
}
Expand Down
Loading
Loading