Commit graph

92 commits

Author SHA1 Message Date
Pedro Rodrigues
eec2731eb2 Fix crash on HTTPClient::poll method
The problem happened because `poll` assumed that when the SSL flag was
true, the `connection` would be a subclass of StreamPeerSSL. However
that invariant could be broken by calling HTTPClient::set_connection
with a `connection` that is not a subclass of StreamPeerSSL.

Fixes #46138

(cherry picked from commit a3a731ed92)
2021-03-04 11:39:51 +01:00
Rémi Verschelde
49646383f1
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆

(cherry picked from commit b5334d14f7)
2021-01-13 16:17:06 +01:00
Haoyu Qiu
8361caad86
Allows HTTPClient to talk to proxy server
* Makes request uri accept absolute URL and authority
* Adds Host header only when missing

(cherry picked from commit d92ca6fbb1)
2020-11-17 12:07:01 +01:00
Hugo Locurcio
2c6b3074fc
Increase the default HTTPClient download chunk size to 64 KiB
This improves download speeds at the cost of increased memory usage.

This change also effects HTTPRequest automatically.

See #32807 and #33862.

(cherry picked from commit 13357095ee)
2020-11-11 15:30:55 +01:00
Haoyu Qiu
9119560d4d
Fixes HTTPClient::poll crash after connection is self-assigned
(cherry picked from commit 8226cee8d8)
2020-10-19 16:10:00 +02:00
Rémi Verschelde
c8859f0463
Fix typos with codespell
Using codespell 1.17.1.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
dof
doubleclick
fave
findn
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2020-09-18 14:09:51 +02:00
Rémi Verschelde
a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Fabio Alessandrelli
6f38aeef52
Merge pull request #33640 from mewin/http_head_request
Fix HTTP HEAD requests
2019-12-01 05:50:33 +01:00
Patrick Wuttke
2cd68a2566 do not wait for response body when making a HEAD request 2019-11-26 14:17:34 +01:00
Rémi Verschelde
967cc2c014
Merge pull request #33862 from Faless/net/http_request_chunk_size
Add download_chunk_size property to HTTPRequest.
2019-11-25 14:29:59 +01:00
Fabio Alessandrelli
ed19b4076e Add download_chunk_size property to HTTPRequest.
This allows setting the `read_chunk_size` of the internal HTTPClient.
This is important to reduce the allocation overhead and number of file
writes when downloading large files, allowing for better download speed.
2019-11-24 19:32:20 +01:00
Artem Burjachenko
b73073ae36 Fix HTTPClient::poll crash when connection set to null 2019-11-23 11:06:14 +04:00
qarmin
3c154eb93b Remove unnecessary code and add some error explanations 2019-07-01 12:59:42 +02:00
qarmin
4e5310cc60 Some code changed with Clang-Tidy 2019-06-26 15:08:25 +02:00
Hein-Pieter van Braam-Stewart
64626f682e Fix a random SSL crash I saw once.
I don't know why this happened, I was debugging another issue. This
should take care of it though.
2019-06-06 13:46:54 +00:00
Rémi Verschelde
e0574e1d98 Fix typos with codespell
Using codespell 1.15.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
doubleclick
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2019-05-19 13:10:35 +02:00
Fabio Alessandrelli
0e5655694c Fix HTTPClient keep alive with chunked encoding.
We need to consume the trailer part and final CRLF after last chunk
as per RFC 7230 section 4.1:

```
chunked-body   = *chunk
                 last-chunk
                 trailer-part
                 CRLF
```

We do not return the trailer part, just consume it allowing following
requests to work as expected when using keep alive.
2019-02-20 05:13:51 +01:00
Fabio Alessandrelli
10e4821260 HTTPClient read until EOF fixes 2019-02-20 03:06:02 +01:00
Fabio Alessandrelli
673caa5f46 Fix keep-alive without header in HTTP client 2019-02-16 17:05:13 +01:00
Rémi Verschelde
b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Rémi Verschelde
7b081a7fc8 Fix warnings about unhandled enum value in switch [-Wswitch]
Fixes GCC 5 warnings of the form:

core/io/http_client.cpp:288:9: warning: enumeration value 'STATUS_SSL_HANDSHAKE_ERROR' not handled in switch [-Wswitch]
core/io/marshalls.cpp:806:9: warning: enumeration value 'AABB' not handled in switch [-Wswitch]

Those can be trivial cases where adding a default fallback is the solution,
or more complex issues/hidden bugs where missed values are actually meant
to be handled.
2018-09-27 18:34:30 +02:00
Fabio Alessandrelli
92de6df113 Add checks for clean disconnect in HTTP/TCP/SSL.
Half-open TCP connection can, of course, only be detected by
writing the socket, or waiting for TCP timeout.
2018-09-21 14:34:57 +02:00
Fabio Alessandrelli
26677d5e0c Fix HTTPClient _get_http_data bug after #21976. 2018-09-15 21:17:15 +02:00
Rémi Verschelde
1259cbf13c
Merge pull request #21976 from Faless/http_client_eof_fix
Fix non chunked HTTP reading till eof.
2018-09-13 11:17:14 +02:00
Rémi Verschelde
1a16dabfb5
Merge pull request #21982 from luzpaz/misc-typos
Misc. typos
2018-09-13 10:59:00 +02:00
luz.paz
08bde5b2de Misc. typos
Found via `codespell -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"`
2018-09-12 21:39:17 -04:00
Fabio Alessandrelli
30327872e0 Unify StreamPeerTCP/TCP_Server with NetSocket API 2018-09-12 15:56:20 +02:00
Fabio Alessandrelli
ab0e610e86 Fix non chunked HTTP reading till eof. 2018-09-12 12:42:48 +02:00
Rémi Verschelde
277b24dfb7 Make core/ includes absolute, remove subfolders from include path
This allows more consistency in the manner we include core headers,
where previously there would be a mix of absolute, relative and
include path-dependent includes.
2018-09-12 09:52:22 +02:00
Hein-Pieter van Braam
0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
Fabio Alessandrelli
9ba8f0d2d8 HTTP client now uses non blocking handshake 2018-07-16 13:08:17 +02:00
GagaPete
8a4dccc4ce Fix CORS problems due to added headers on JS target
Before this change, missing User-Agent and Accept headers were automatically
added on all platforms. Setting the User-Agent header forces the browser to
do a CORS preflight (see 1) which fails if the HTTP endpoint is not
configured appropriate. It's not neccesary to set either header as the
browser sets them and so this commit disables that functionality on the JS
target.

1: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests
2018-07-04 01:56:44 +02:00
Pedro J. Estébanez
2587fcccee Allow body-up-to-EOF HTTP responses
Implements the same heuristic as Curl (and web browsers): if no `Content-Length`, no `Connection: keep-alive` and no chunked transfer encoding, assume th rest of the data until EOF is the body, gracefully setting the HTTP client back to the disconnected state.

Theoretically, this is not compliant with HTTP 1.1, by which `keep-alive` is the default, but in practice, an explicit header is sent by servers.
2018-05-22 15:08:31 +02:00
Pedro J. Estébanez
00e98458ba Revert "Unify http- and percent- encode/decode"
This reverts commit b76ee30917.
2018-04-12 21:12:34 +02:00
Pedro J. Estébanez
8d8e9d54c8 Enhance HTTPClient.query_string_from_dict() 2018-03-27 19:18:32 +02:00
Pedro J. Estébanez
b76ee30917 Unify http- and percent- encode/decode
There was a percent-prefixed version, which was exposed, and a http-prefixed version which was not (only to GDNative).
This commit keeps the percent-prefixed versions, but with the http-prefixed implementations.
2018-03-27 19:18:30 +02:00
Pedro J. Estébanez
602da6fa4f Fix wrong SSL handshake
The name of the remote host is passed to mbed TLS in all cases so the client hello message is correctly formed.
2018-03-04 01:22:59 +01:00
Bojidar Marinov
9b8e8b2220
Bind many more properties to scripts
Notable potentially breaking changes:
- PROPERTY_USAGE_NOEDITOR is now PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_NETWORK, without PROPERTY_USAGE_INTERNAL
- Some properties were renamed, and sometimes even shadowed by new ones
- New getter methods (some virtual) were added
2018-01-12 00:58:14 +02:00
Rémi Verschelde
e4213e66b2 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Rémi Verschelde
b50a9114b1 Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
Fabio Alessandrelli
206275f3e7 Fix javascript build error and improve #14604 2017-12-15 15:35:18 +01:00
mhilbrunner
966c054fc9 HTTP cleanup & better defaults 2017-12-14 10:59:42 +01:00
mhilbrunner
a7abb459c9 HTTPClient: Add PATCH method and missing HTTP status codes 2017-12-12 10:56:18 +01:00
Leon Krause
2970061a73 Implement HTTPClient in HTML5 platform
Limitations:

 - Subject to same-origin policy
 - No persistent connection (but simulated for compatibility)
 - No blocking mode
 - No StreamPeer access
 - No chunked responses
 - Cannot disable host verification
2017-11-13 00:58:29 +01:00
Leon Krause
d1102cb37d Remove HTTPClient::send_body_text and ::send_body_data
These were never implemented, the request* methods provide parameters to
send body data as part of the client's requests.
2017-10-26 22:25:35 +02:00
Nathan Warden
310a8eb902 Fixed a bug where ssl would force validation even though you told it not to. 2017-10-03 13:53:23 -05:00
Rémi Verschelde
bd282ff43f Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
Ignacio Etcheverry
32dd9a9f66 ClassDB: Provide the enum name of integer constants 2017-08-20 22:07:43 +02:00
Ignacio Etcheverry
2f290038d6 Removes type information from method binds 2017-08-10 07:17:50 +02:00
Martin Capitanio
5cabe5f0fc Don't append standard ports to the request header.
Breaks the SSL communication with some servers,
do the same that the other curl, wget, firefox & co clients do.

Fixes #9146
2017-06-13 22:58:23 +02:00