Commit Graph

85 Commits

Author SHA1 Message Date
Nicholas Nethercote
73f4ef584f
hyper: fix a progress upload counter bug
`Curl_pgrsSetUploadCounter` should be a passed a total count, not an
increment.

This changes the failing diff for test 579 with hyper from this:
```
 Progress callback called with UL 0 out of 0[LF]
-Progress callback called with UL 8 out of 0[LF]
-Progress callback called with UL 16 out of 0[LF]
-Progress callback called with UL 26 out of 0[LF]
-Progress callback called with UL 61 out of 0[LF]
-Progress callback called with UL 66 out of 0[LF]
+Progress callback called with UL 29 out of 0[LF]
```
to this:
```
 Progress callback called with UL 0 out of 0[LF]
-Progress callback called with UL 8 out of 0[LF]
-Progress callback called with UL 16 out of 0[LF]
-Progress callback called with UL 26 out of 0[LF]
-Progress callback called with UL 61 out of 0[LF]
-Progress callback called with UL 66 out of 0[LF]
+Progress callback called with UL 40 out of 0[LF]
```
Presumably a step in the right direction.

Closes #11780
2023-09-01 14:44:12 +02:00
Nicholas Nethercote
9b84f274f1
hyper: fix ownership problems
Some of these changes come from comparing `Curl_http` and
`start_CONNECT`, which are similar, and adding things to them that are
present in one and missing in another.

The most important changes:
- In `start_CONNECT`, add a missing `hyper_clientconn_free` call on the
  happy path.
- In `start_CONNECT`, add a missing `hyper_request_free` on the error
  path.
- In `bodysend`, add a missing `hyper_body_free` on an early-exit path.
- In `bodysend`, remove an unnecessary `hyper_body_free` on a different
  error path that would cause a double-free.
  https://docs.rs/hyper/latest/hyper/ffi/fn.hyper_request_set_body.html
  says of `hyper_request_set_body`: "This takes ownership of the
  hyper_body *, you must not use it or free it after setting it on the
  request." This is true even if `hyper_request_set_body` returns an
  error; I confirmed this by looking at the hyper source code.

Other changes are minor but make things slightly nicer.

Closes #11745
2023-08-28 11:06:15 +02:00
Nicholas Nethercote
e854166472
c-hyper: fix another memory leak in Curl_http.
There is a `hyper_clientconn_free` call on the happy path, but not one
on the error path. This commit adds one.

Fixes the second memory leak reported by Valgrind in #10803.

Fixes #10803
Closes #11729
2023-08-25 15:27:22 +02:00
Nicholas Nethercote
c61dd5fed2
c-hyper: fix a memory leak in Curl_http.
A request created with `hyper_request_new` must be consumed by either
`hyper_clientconn_send` or `hyper_request_free`.

This is not terrifically clear from the hyper docs --
`hyper_request_free` is documented only with "Free an HTTP request if
not going to send it on a client" -- but a perusal of the hyper code
confirms it.

This commit adds a `hyper_request_free` to the `error:` path in
`Curl_http` so that the request is consumed when an error occurs after
the request is created but before it is sent.

Fixes the first memory leak reported by Valgrind in #10803.

Closes #11729
2023-08-25 15:27:11 +02:00
Daniel Stenberg
5e2beb3395
spelling: use 'reuse' not 're-use' in code and elsewhere
Unify the spelling as both versions were previously used intermittently

Closes #11717
2023-08-23 23:22:36 +02:00
Daniel Stenberg
850f6c79e8
c-hyper: adjust the hyper to curlcode conversion
Closes #11621
2023-08-08 23:27:42 +02:00
Daniel Stenberg
3ee79c1674
http: return error when receiving too large header set
To avoid abuse. The limit is set to 300 KB for the accumulated size of
all received HTTP headers for a single response. Incomplete research
suggests that Chrome uses a 256-300 KB limit, while Firefox allows up to
1MB.

Closes #11582
2023-08-03 17:08:13 +02:00
Stefan Eissing
def99e011e
hyper: fix EOF handling on input
We ran out of disc space due to an infinite loop with debug logging

Fixes #11377
Closes #11385
Reported-by: Dan Fandrich
2023-07-08 23:01:24 +02:00
Stefan Eissing
81e6793ec9
hyper: unslow
- refs #11203 where hyper was reported as being slow
- fixes hyper_executor_poll to loop until it is out of
  tasks as advised by @seanmonstar in https://github.com/hyperium/hyper/issues/3237
- added a fix in hyper io handling for detecting EAGAIN
- added some debug logs to see IO results
- pytest http/1.1 test cases pass
- pytest h2 test cases fail on connection reuse. HTTP/2
  connection reuse does not seem to work. Hyper submits
  a request on a reused connection, curl's IO works and
  thereafter hyper declares `Hyper: [1] operation was canceled: connection closed`
  on stderr without any error being logged before.

Fixes #11203
Reported-by: Gisle Vanem
Advised-by: Sean McArthur
Closes #11344
2023-06-20 09:11:41 +02:00
Emanuele Torre
f198d33e8d
checksrc: disallow spaces before labels
Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
the line is the favoured style overall with 329 instances.

Out of the 86 labels not at the start of the line:
* 75 were indented with the same indentation level of the following line
* 8 were indented with exactly one space
* 2 were indented with one fewer indentation level then the following
  line
* 1 was indented with the indentation level of the following line minus
  three space (probably unintentional)

Co-Authored-By: Viktor Szakats

Closes #11134
2023-05-18 20:45:04 +02:00
Daniel Stenberg
2e2e3d16c5
ws: fix recv of larger frames
+ remove 'oleft' from the struct
 + deal with "overflow data" in a separate dynbuf

Reported-by: Mike Duglas
Fixes #10438
Closes #10447
2023-02-10 08:28:58 +01:00
Daniel Stenberg
2bc1d775f5
copyright: update all copyright lines and remove year ranges
- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- saves us from pointless churn
- git keeps history for us
- the year range is kept in COPYING

checksrc is updated to allow non-year using copyright statements

Closes #10205
2023-01-03 09:19:21 +01:00
Daniel Stenberg
5c544b4912
c-hyper: move down the Accept-Encoding header generation
To match the internal HTTP request header order so that test 1277 works
again.

Closes #10200
2023-01-02 11:51:30 +01:00
Prithvi MK
b80dae232e
c-hyper: fix multi-request mechanism
It makes test 565 run fine.

Fixes #8896
Closes #10080
Assisted-by: Daniel Stenberg
2022-12-11 14:15:53 +01:00
Daniel Stenberg
c8d24d4e77
c-hyper: CONNECT respones are not server responses
Together with d31915a8db it makes test 265 run fine.

Fixes #8853
Assisted-by: Prithvi MK
Assisted-by: Sean McArthur
Closes #10060
2022-12-08 23:36:23 +01:00
Sean McArthur
8c859cdb69
hyper: classify headers as CONNECT and 1XX
Closes #9947
2022-11-19 13:01:12 +01:00
Stefan Eissing
9ad386f85b
hyper: fix handling of hyper_task's when reusing the same address
Fixes #9840
Closes #9860
2022-11-07 12:19:36 +01:00
Daniel Stenberg
52cc4a85fd
style: use space after comment start and before comment end
/* like this */

/*not this*/

checksrc is updated accordingly

Closes #9828
2022-10-30 22:31:29 +01:00
Ayesh Karunaratne
4484270afc
misc: typo and grammar fixes
- Replace `Github` with `GitHub`.
- Replace `windows` with `Windows`
- Replace `advice` with `advise` where a verb is used.
- A few fixes on removing repeated words.
- Replace `a HTTP` with `an HTTP`

Closes #9802
2022-10-27 10:01:30 +02:00
Daniel Stenberg
664249d095
ws: initial websockets support
Closes #8995
2022-09-09 15:11:14 +02:00
Daniel Stenberg
472f1cbe7e
NPN: remove support for and use of
Next Protocol Negotiation is a TLS extension that was created and used
for agreeing to use the SPDY protocol (the precursor to HTTP/2) for
HTTPS. In the early days of HTTP/2, before the spec was finalized and
shipped, the protocol could be enabled using this extension with some
servers.

curl supports the NPN extension with some TLS backends since then, with
a command line option `--npn` and in libcurl with
`CURLOPT_SSL_ENABLE_NPN`.

HTTP/2 proper is made to use the ALPN (Application-Layer Protocol
Negotiation) extension and the NPN extension has no purposes
anymore. The HTTP/2 spec was published in May 2015.

Today, use of NPN in the wild should be extremely rare and most likely
totally extinct. Chrome removed NPN support in Chrome 51, shipped in
June 2016. Removed in Firefox 53, April 2017.

Closes #9307
2022-09-05 07:39:02 +02:00
Sean McArthur
3b52a80c05
hyper: enable obs-folded multiline headers
Closes #9216
2022-07-28 00:36:18 +02:00
Daniel Stenberg
74d47e22aa
sendf: make Curl_debug a void function
As virtually no called checked the return code, and those that did
wrongly treated it as a CURLcode. Detected by the icc compiler warning:
enumerated type mixed with another type

Closes #9179
2022-07-23 13:38:43 +02:00
Sean McArthur
be8d2b037d
hyper: use wakers for curl pause/resume
Closes #9070
2022-06-30 10:19:08 +02:00
max.mehl
ad9bc5976d
copyright: make repository REUSE compliant
Add licensing and copyright information for all files in this repository. This
either happens in the file itself as a comment header or in the file
`.reuse/dep5`.

This commit also adds a Github workflow to check pull requests and adapts
copyright.pl to the changes.

Closes #8869
2022-06-13 09:13:00 +02:00
Daniel Stenberg
b67dcc8ed7
c-hyper: mark status line as status for Curl_client_write()
To make sure the headers API can filter it out as not a regular header.

Reported-by: Gisle Vanem
Fixes #8894
Closes #8914
2022-05-25 13:07:12 +02:00
Daniel Stenberg
5a4dbb8ae3
hyper: use 'alt-used'
Makes test 412+413 work

Closes #8898
2022-05-23 16:47:17 +02:00
Garrett Squire
652fd3fab8
hyper: fix test 357
This change fixes the hyper API such that PUT requests that receive a
417 response can retry without the Expect header.

Closes #8811
2022-05-08 23:19:05 +02:00
Liam Warfield
aad7d9f9a6
hyper: fix tests 580 and 581 for hyper
Hyper now has the ability to preserve header order. This commit adds a
few lines setting the connection options for this feature.

Related to issue #8617
Closes #8707
2022-04-25 17:33:08 +02:00
Daniel Stenberg
6968fb9d54
lib: remove exclamation marks
... from infof() and failf() calls. Make them less attention seeking.

Closes #8713
2022-04-16 11:55:05 +02:00
Daniel Stenberg
7da29df6d3
hyper: fix status_line() return code
Detected while working on #7708 that happened to trigger an error here
with a new test case.

Closes #8572
2022-03-10 17:35:46 +01:00
HenrikHolst
9bc3cebc92
misc: remove strlen for Curl_checkheaders + Curl_checkProxyheaders
Closes #8409
2022-02-10 08:51:06 +01:00
HenrikHolst
b807219292
misc: reduce strlen() calls with Curl_dyn_add()
Use STRCONST() to switch from Curl_dyn_add() to Curl_dyn_addn() for
string literals.

Closes #8398
2022-02-09 13:52:47 +01:00
Daniel Stenberg
bc8674d87d
c-hyper: make CURLOPT_SUPPRESS_CONNECT_HEADERS work
Verified by the enabled test 1288

Closes #7905
2021-10-25 23:32:45 +02:00
Daniel Stenberg
10883eb981
c-hyper: don't abort CONNECT responses early when auth-in-progress
... and make sure to stop ignoring the body once the CONNECT is done.

This should make test 206 work proper again and not be flaky.

Closes #7889
2021-10-22 12:54:12 +02:00
Daniel Stenberg
cf088201a9
c-hyper: make test 217 run
Closes #7889
2021-10-22 12:54:00 +02:00
Jay Satiro
b1d08d295f http: set content length earlier
- Make content length (ie download size) accessible to the user in the
  header callback, but only after all headers have been processed (ie
  only in the final call to the header callback).

Background:

For a long time the content length could be retrieved in the header
callback via CURLINFO_CONTENT_LENGTH_DOWNLOAD_T as soon as it was parsed
by curl.

Changes were made in 8a16e54 (precedes 7.79.0) to ignore content length
if any transfer encoding is used. A side effect of that was that
content length was not set by libcurl until after the header callback
was called the final time, because until all headers are processed it
cannot be determined if content length is valid.

This change keeps the same intention --all headers must be processed--
but now the content length is available before the final call to the
header function that indicates all headers have been processed (ie
a blank header).

Bug: https://github.com/curl/curl/commit/8a16e54#r57374914
Reported-by: sergio-nsk@users.noreply.github.com

Co-authored-by: Daniel Stenberg

Fixes https://github.com/curl/curl/issues/7804
Closes https://github.com/curl/curl/pull/7803
2021-10-15 03:40:16 -04:00
Daniel Stenberg
a3030b7db6
c-hyper: make Curl_http propagate errors better
Pass on better return codes when errors occur within Curl_http instead
of insisting that CURLE_OUT_OF_MEMORY is the only possible one.

Pointed-out-by: Jay Satiro
Closes #7851
2021-10-14 07:49:09 +02:00
Daniel Stenberg
4e0c28923a
c-hyper: use hyper_request_set_uri_parts to make h2 better
and make sure to not send Host: over h2.

Fixes #7679
Reported-by: David Cook
Closes #7827
2021-10-08 15:14:29 +02:00
Daniel Stenberg
8a16e54c0c
http: ignore content-length if any transfer-encoding is used
Fixes #7643
Closes #7649
2021-08-31 10:04:03 +02:00
Daniel Stenberg
e5d77dc2ca
c-hyper: handle HTTP/1.1 => HTTP/1.0 downgrade on reused connection
Enable test 1074

Closes #7617
2021-08-23 16:12:33 +02:00
Daniel Stenberg
38941ad6f3
c-hyper: deal with Expect: 100-continue combined with POSTFIELDS
Enable test 1130 and 1131

Closes #7616
2021-08-23 16:10:15 +02:00
Daniel Stenberg
f46b83fc94
c-hyper: initial support for "dumping" 1xx HTTP responses
With the use hyper_request_on_informational()

Enable test 155 and 158

Closes #7597
2021-08-20 13:37:43 +02:00
Daniel Stenberg
32f6812b5a
c-hyper: initial step for 100-continue support
Enabled test 154

Closes #7568
2021-08-13 23:18:21 +02:00
Daniel Stenberg
1e0b6f705e
c-hyper: fix header value passed to debug callback
Closes #7567
2021-08-13 17:37:02 +02:00
Daniel Stenberg
2c688a4aae
c-hyper: remove the hyper_executor_poll() loop from Curl_http
1. it's superfluous
2. it didn't work identically to the Curl_hyper_stream one which could
   cause problems like #7486

Pointed-out-by: David Cook
Closes #7499
2021-07-27 10:42:47 +02:00
Daniel Stenberg
e7416cfd2b
infof: remove newline from format strings, always append it
- the data needs to be "line-based" anyway since it's also passed to the
  debug callback/application

- it makes infof() work like failf() and consistency is good

- there's an assert that triggers on newlines in the format string

- Also removes a few instances of "..."

- Removes the code that would append "..." to the end of the data *iff*
  it was truncated in infof()

Closes #7357
2021-07-07 22:54:01 +02:00
Daniel Stenberg
c3d612662d
test1147: hyper doesn't allow "crazy" request headers like built-in
... so strip that from the test.

Closes #7349
2021-07-05 22:51:13 +02:00
Daniel Stenberg
a62ece3f57
c-hyper: bail on too long response headers
To match with built-in behaviors. Makes test 1154 work.

Closes #7350
2021-07-05 22:49:12 +02:00
Daniel Stenberg
0b0269341b
c-hyper: add support for transfer-encoding in the request
Closes #7348
2021-07-05 22:46:01 +02:00