JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.97k stars 385 forks source link

HEAD requests are sent using HTTP/1.0 even when protocol is set to HTTP/1.1 #229

Open jasons42 opened 1 year ago

jasons42 commented 1 year ago

Here is my config which has gmethod = HEAD and protocol = HTTP/1.1 set:

CURRENT  SIEGE  CONFIGURATION
Mozilla/5.0 (apple-arm-darwin23.0.0) Siege/4.1.6
Edit the resource file to change the settings.
----------------------------------------------
version:                        4.1.6
verbose:                        true
color:                          true
quiet:                          false
debug:                          false
protocol:                       HTTP/1.1
HTML parser:                    enabled
get method:                     HEAD
connection:                     close
concurrent users:               25
time to run:                    n/a
repetitions:                    n/a
socket timeout:                 30
cache enabled:                  false
accept-encoding:                gzip, deflate
delay:                          0.000 sec
internet simulation:            false
benchmark mode:                 false
failures until abort:           1024
named URL:                      none
URLs file:                      /opt/homebrew/Cellar/siege/4.1.6/etc/urls.txt
thread limit:                   255
logging:                        false
log file:                       /opt/homebrew/var/log/siege.log
resource file:                  /Users/jsmith/.siege/siege.conf
timestamped output:             false
comma separated output:         false
allow redirects:                true
allow zero byte data:           true
allow chunked encoding:         true
upload unique files:            true
json output:                    false
no-follow:
 - ad.doubleclick.net
 - pagead2.googlesyndication.com
 - ads.pubsqrd.com
 - ib.adnxs.com
proxy auth:
www auth:

Despite this when I send a request using -g I see that a HEAD request is sent, but using HTTP/1.0 instead of HTTP/1.1:

HEAD /siege-home/ HTTP/1.0
Host: www.joedog.org
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (apple-arm-darwin23.0.0) Siege/4.1.6
Connection: close

HTTP/1.1 200 OK
Date: Tue, 21 Nov 2023 21:17:32 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
X-Powered-By: PHP/7.3.33
Set-Cookie: wp_wpfileupload_0=kE67eeGA2HPrwOdfRNhmHZNFOHms2cd6; expires=Thu, 23-Nov-2023 21:17:32 GMT; Max-Age=172800; path=/
X-Pingback: https://www.joedog.org/xmlrpc.php
Link: <https://www.joedog.org/wp-json/>; rel="https://api.w.org/"
Link: <https://www.joedog.org/wp-json/wp/v2/pages/18>; rel="alternate"; type="application/json"
Link: <https://www.joedog.org/?p=18>; rel=shortlink
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=2nZo6%2F7MF2XOlTtvbME6fQil4KgytSVuGWOYuYJsqDbKF6WOwxWIhxaVtRqxWc7Ch4Jhh%2FhHy99tSWe9dx9YePIbb%2BsrThJgM%2BY1QWBZvz%2BaMRTHcVpeA6HWtO1Ne6dupQ%3D%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 829bf5c20fd71267-ORD
Content-Encoding: gzip
alt-svc: h3=":443"; ma=86400

This is an issue for me as we have proxies/loadbalancers configured to reject HTTP/1.0 requests and return 426 Upgrade Required.

dchekmarev commented 8 months ago

I believe this might be the cause: https://github.com/JoeDog/siege/blob/68a7101e15a3667e4182ea00d2132c3ef252dc3d/src/http.c#L154

  if (my.protocol == FALSE || my.get == TRUE || my.print == TRUE) {
    snprintf(protocol, sizeof(protocol), "HTTP/1.0");
  } else {
    snprintf(protocol, sizeof(protocol), "HTTP/1.1");
  }

For me this looks like ignoring protocol setting, if we're in -g or -p mode it enforces HTTP/1.0