`Expect: 100-continue` not handled properly in PUT
In https://gitlab.gnome.org/GNOME/phodav/-/blob/master/libphodav/phodav-method-put.c#L77-78, if the Expect
header if present, a warning is created, but no special handling is done. Instead, status
is set to either SOUP_STATUS_CREATED
or SOUP_STATUS_OK
.
As per the SoupServer documentation, if status
if set and the Expect
header if present, the status will be returned and no further processing will be done:
(At this point, if the request headers contain "Expect: 100-continue", and a status code has been set, then SoupServer will skip the remaining steps and return the response. If the request headers contain "Expect: 100-continue" and no status code has been set, SoupServer will return a SOUP_STATUS_CONTINUE status before continuing.)
This is a problem because curl --upload-file
will send a PUT
request with a Expect: 100-continue
header, and instead of phodav sending a 100
response and waiting for the body, it sends wither 200
or 201
.
Here is the output of curl -T test.txt http://localhost:9843 -o /dev/stdout -vvv
, with spice-webdavd
running on port 9843:
* Trying 127.0.0.1:9843...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to localhost (127.0.0.1) port 9843 (#0)
> PUT /test.txt HTTP/1.1
> Host: localhost:9843
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 14
> Expect: 100-continue
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 201 Created
< Server: PhodavServer libsoup/2.65.1
< Date: Wed, 26 Jan 2022 03:10:06 GMT
< Content-Length: 0
<
0 14 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Connection #0 to host localhost left intact
In contrast, when running the simple-httpd
file from the libsoup examples, with it listening on port 33467
, and running curl -T test.txt http://localhost:33467 -o /dev/stdout -vvv
, the output is:
* Trying 127.0.0.1:33467...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to localhost (127.0.0.1) port 33467 (#0)
> PUT /test.txt HTTP/1.1
> Host: localhost:33467
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 14
> Expect: 100-continue
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 100 Continue
< Server: simple-httpd libsoup/3.0.4
< Date: Wed, 26 Jan 2022 03:14:19 GMT
} [14 bytes data]
* We are completely uploaded and fine
* Mark bundle as not supporting multiuse
< HTTP/1.1 201 Created
< Content-Length: 0
<
100 14 0 0 100 14 0 11137 --:--:-- --:--:-- --:--:-- 14000
* Connection #0 to host localhost left intact