-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Description
When curl send two requests and second one closing by timeout, curl reconnect and send it one more times. This happend only if CURLOPT_CUSTOMREQUEST was used.
Client code:
<?php
declare(strict_types=1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, "http://localhost");
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://localhost");
curl_exec($ch);
curl_close($ch);Server code written on Go 1.21:
package main
import (
"log"
"net/http"
"time"
)
type Handler struct {
amount int
}
func (p *Handler) ServeHTTP(respw http.ResponseWriter, req *http.Request) {
log.Printf("Got %s request %v from %s\n", req.Method, req.URL.String(), req.RemoteAddr)
p.amount += 1
if p.amount == 2 {
time.Sleep(time.Second * 5)
}
return
}
func main() {
h := Handler{}
srv := http.Server{
Addr: ":80",
Handler: &h,
ReadTimeout: 2 * time.Second,
WriteTimeout: 2 * time.Second,
}
srv.ListenAndServe()
}Resulted in this output:
2023/10/16 14:04:19 Got POST request / from 172.18.0.12:35374
2023/10/16 14:04:19 Got POST request / from 172.18.0.12:35374
2023/10/16 14:04:24 Got POST request / from 172.18.0.12:47144
But I expected this output instead:
2023/10/16 14:04:19 Got POST request / from 172.18.0.12:35374
2023/10/16 14:04:19 Got POST request / from 172.18.0.12:35374
PHP Version
php 7.4-8.1
Operating System
Ubuntu 20.04, Alpine 3.11.3