1
0
mirror of https://git.kore.io/kore.git synced 2024-11-15 22:46:21 +01:00
Commit Graph

1077 Commits

Author SHA1 Message Date
Joris Vink
192f458f97 remove unused variable. 2016-01-18 11:43:44 +01:00
Joris Vink
a2216c84b0 Properly check if path was already set. 2016-01-18 11:43:10 +01:00
Joris Vink
fcb86ddb8b Massive rework of HTTP layer.
This commit is a flag day, your old modules will almost certainly
need to be updated in order to build properly with these changes.

Summary of changes:

- Offload HTTP bodies to disk if they are large (inspired by #100).
  (disabled by default)
- The http_argument_get* macros now takes an explicit http_request parameter.
- Kore will now throw 404 errors almost immediately after an HTTP request
  has come in instead of waiting until all data has arrived.

API changes:

- http_argument_get* macros now require an explicit http_request parameter.
  (no more magic invokations).
- http_generic_404() is gone
- http_populate_arguments() is gone
- http_body_bytes() is gone
- http_body_text() is gone
- http_body_read() has been added
- http_populate_post() has been added
- http_populate_get() has been added
- http_file_read() has been added
- http_file_rewind() has been added
- http_file_lookup() no longer takes name, fname, data and len parameters.
- http_file_lookup() now returns a struct http_file pointer.
- http_populate_multipart_form() no longer takes an secondary parameter.

New configuration options:

- http_body_disk_offload:
	Number of bytes after which Kore will offload the HTTP body to
	disk instead of retaining it in memory. If 0 this feature is
	disabled. (Default: 0)

- http_body_disk_path:
	The path where Kore will store temporary HTTP body files.
	(this directory does not get created if http_body_disk_offload is 0).

New example:

The upload example has been added, demonstrating how to deal with file
uploads from a multipart form.
2016-01-18 11:30:22 +01:00
Joris Vink
96641d3caa Merge branch 'master' of /opt/git/kore 2016-01-18 11:29:47 +01:00
Joris Vink
0dcd6087cf Add kore_buf_stringify().
NUL-terminates a kore_buf and returns a char pointer.
2016-01-18 11:26:55 +01:00
Joris Vink
4706c9a2b4 tls_dhparam is required, mention this in example 2016-01-14 10:55:29 +01:00
Joris Vink
3c40168e50 Deal with SSL_ERROR_SYSCALL properly. 2016-01-14 10:50:46 +01:00
Joris Vink
bc6e46eb5f Merge pull request #102 from ansend/master
Retry read/write if EINTR is given instead of error-ing out.
2016-01-14 10:40:53 +01:00
Ansen Dong
490163de4a if read() return EINTER,retry 2016-01-14 03:02:53 -05:00
Joris Vink
ed8110f109 Paranoia about overflows. 2016-01-09 13:51:50 +01:00
Joris Vink
0aae500e2f Merge pull request #101 from CarlEkerot/ce-buf-append-fix
Don't reallocate a buffer if we do not need to.
2016-01-09 13:40:15 +01:00
Carl Ekerot
53e8220ff6 Fix off-by-one error when reallocing buffer
There was an invalid boundary check when appending to a buffer. The
consequence of this was that the POST data buffer was deterministically
realloced.
2016-01-09 01:57:59 +01:00
Joris Vink
e580e6678e Simplify checking filename component. 2016-01-08 21:19:37 +01:00
Joris Vink
ce874f09ea Cut memory usage for incoming HTTP bodies in half.
Kore pre-allocates a kore_buf for the full size of the
incoming HTTP body ... but also was passing the full
size to the net_recv_reset() function.

Instead of this, properly read smaller chunks from the
network and append them to the body buffer as they roll in.
2016-01-08 20:56:21 +01:00
Joris Vink
0647901ef5 Improve http_body_max directive a bit.
Allow setting it to 0 which will disable HTTP requests
that have a body (POST/PUT).

Reduce default http_body_max to 1MB by default, 10MB seems large.

Revisit to this code inspired by #100.
2016-01-08 17:54:40 +01:00
Joris Vink
0c47574fe9 If a body is too large send a 413 instead of 411. 2016-01-08 17:47:15 +01:00
Joris Vink
f2d8834e8e After receiving a body, prime the netbuf again.
Not doing this results in nothing being read anymore
from the connection after a POST with a content-length of > 0.

Found by Xuning Niu.
2016-01-07 10:40:33 +01:00
Joris Vink
e9b56c81a5 Do not fatal if no listeners are defined. 2016-01-07 10:09:44 +01:00
Joris Vink
2f4387e0cd correct headers. 2016-01-07 09:24:45 +01:00
Joris Vink
07ed037a00 Reduce memory footprint for NOTLS builds. 2016-01-07 09:20:09 +01:00
Stig Telfer
18d3cc032d rename *_fini to *_cleanup 2016-01-04 21:40:14 +00:00
Joris Vink
2fc326c0ce Remove whitespace. 2016-01-04 13:09:45 +01:00
Joris Vink
c4b1206ae3 Bump copyright to 2016. 2016-01-04 12:58:51 +01:00
Joris Vink
a281fd5713 Introduce synchronous pgsql queries.
Semantics for using pgsql API have changed quite heavily
with this commit. See the examples for more information.

Based on Github issue #95 by PauloMelo (paulo.melo@vintageform.pt)
with several modifications by me.
2016-01-04 11:12:43 +01:00
Stig Telfer
223c5c4c28 net_send_queue: Handle case where new data exactly fits available buffer. 2015-12-29 22:07:24 +00:00
Stig Telfer
ac45e8cd62 Revert incorrect parameter validation 2015-12-29 21:29:35 +00:00
Stig Telfer
0c51d9da53 Add resource management as part of the kore shutdown process. 2015-12-29 19:39:39 +00:00
Joris Vink
8368f6d471 Updated comment section on worker_accept_threshold. 2015-12-20 11:21:40 +01:00
Joris Vink
6bfeb8e037 Clearify worker configuration directive. 2015-12-20 11:19:07 +01:00
Joris Vink
4356c3e628 Allow domain wildcards in the configuration. 2015-12-16 19:51:06 +01:00
Joris Vink
519c3c16d4 Do not run kore_split_string() on original cookie
This broke after http_request_header() started returning
a pointer to the actual header value instead of a copy.

Reminded by PauloMelo via github.
2015-12-14 18:48:48 +01:00
Joris Vink
5f7709211b Merge pull request #92 from PauloMelo/master
add kore_buf_reset
2015-12-11 23:41:52 +01:00
PauloMelo
a6ccf2bae9 correct tabsize 2015-12-11 22:31:14 +00:00
PauloMelo
d811bf71dc add kore_buf_reset 2015-12-11 21:31:59 +00:00
Joris Vink
8a6f4a935e Set handle function pointer for message callbacks. 2015-12-10 09:26:24 +01:00
Joris Vink
6ac15d37cb Make sure user agent is still set properly. 2015-12-10 09:25:22 +01:00
Joris Vink
c3401fe348 Make the TLS proxy example much better.
Now allows multiple backends based on SNI that was
set during TLS handshake.

The connection phase for the backends is now fully
non blocking.
2015-12-09 21:29:53 +01:00
Joris Vink
d3332d5921 Add kore_platform_schedule_write(). 2015-12-09 21:29:44 +01:00
Joris Vink
3c0cc79e6b More incompatible changes incoming, make it clear
Semver demands it.
2015-12-09 16:29:35 +01:00
Joris Vink
ef708bd3b7 Merge pull request #89 from Houdini/master
fix typo: -r for skip privs
2015-12-08 08:50:37 +01:00
Dmitrii Golub
3eaa325eb5 fix typo: -r for skip privs 2015-12-08 04:42:16 +03:00
Joris Vink
c95aac54a2 Merge pull request #87 from Houdini/master
Better CFLAGS and CFLAGS limit
2015-12-04 22:57:32 +01:00
Dmitrii Golub
ab391df7ff Better CFLAGS and CFLAGS limit 2015-12-04 17:16:56 +03:00
Joris Vink
d7bbb54424 Remove zlib.h 2015-12-04 14:12:06 +01:00
Joris Vink
b4611ee38d Kill off zlib_dict.c 2015-12-04 14:11:37 +01:00
Joris Vink
77364e49cd Do not call handle if not set, similar to bsd.c. 2015-12-02 21:57:16 +01:00
Joris Vink
1ed96b12a9 correct certificate path in example 2015-12-02 21:53:42 +01:00
Joris Vink
d02f9e549f Add TLS proxy example. 2015-12-02 21:52:26 +01:00
Joris Vink
961a2e3685 Allow apps to override connection handling.
Setting the handle callback allows your application
to take care of network events for the connection.

Look at the connection state and flags to determine
if read/write is possible and go from there.

See kore_connection_handle() for more details.
2015-12-01 20:55:00 +01:00
Joris Vink
428802afc8 More cleanup after introducing NOHTTP=1.
* The cli tools must know when building as KORE_NO_HTTP.
* Reshuffle some structs around to avoid forward declarations.
* Move wscbs under !KORE_NO_HTTP as its for websockets.
* Remove unused members from struct connection.

Applications that use the connect callbacks for new connections
must now set the connection state themselves, see nohttp example.
2015-11-30 16:23:34 +01:00