Commit Graph

1048 Commits

Author SHA1 Message Date
Joris Vink d0e9441b60 remove debug. 2016-02-01 21:41:25 +01:00
Joris Vink c8484ee9ab Redo config parsing a bit.
No longer just call kore_string_split() on the line
but separate out the configuration directive and let
the appropriate callbacks parse things on their own.
2016-02-01 21:33:51 +01:00
Joris Vink 82a9e6ef59 Formatting and unbreaking NOHTTP builds. 2016-02-01 20:02:02 +01:00
Joris Vink f4d00645ed Merge pull request #99 from oneswig/master
Add resource management as part of the kore shutdown process.
2016-02-01 19:51:27 +01:00
Joris Vink 1f5e482b8a Build option changes.
- Build with -O2 unless NOOPT is set to 1.
- Hide -g behind DEBUG instead of always building with it.
- Explicitely set the standard used to c99, use pedantic.
2016-02-01 15:33:40 +01:00
Stig Telfer 7963a2deaa Added cleanup for the module handlers and validators 2016-02-01 12:13:22 +00:00
Stig Telfer 55d2451b90 Add cleanup of http_body_path pool 2016-02-01 10:10:04 +00:00
Stig Telfer bd975541dd Merge branch 'master' into oneswig 2016-02-01 10:04:59 +00:00
Joris Vink f2f5a3742f Let SIGTERM properly shutdown Kore as well. 2016-01-31 16:48:17 +01:00
Joris Vink cb489ce80f Define WAIT_ANY if not defined previously. 2016-01-31 16:47:00 +01:00
Joris Vink 3284265b74 Remove the -v stuff and always show cflags and ldflags. 2016-01-27 21:37:59 +01:00
Joris Vink b777ea65cd Long day .. actually add the new build flavor code. 2016-01-27 21:32:57 +01:00
Joris Vink c5ce707a91 Introduce build flavors.
Kore applications now get a build.conf which may contain different
build flavors. Each flavor can get its own cflags or ldflags.

This was in parts inspired by #106.

A new cli command has been added:
kore flavor

This command allows you to see all flavors and switch between them.
The kore build command now also takes a -v argument which if given
dumps the used CFLAGS and LDFLAGS out to stdout.

For existing applications the build.conf is automatically generated
next time you run kore build or kore run.

Also fixed a bug in the json_yajl example, sneaky change here.
2016-01-27 21:29:59 +01:00
Joris Vink 8282baf63d s/http/https/ 2016-01-27 08:42:08 +01:00
Joris Vink 702ebd1a8d Mention IRC channel on freenode. 2016-01-27 08:41:16 +01:00
Stig Telfer 2ac6e7d41d Merge branch 'master' into oneswig 2016-01-24 13:46:38 +00:00
Joris Vink 340bcb3b0d Properly queue net events for tls-proxy example 2016-01-22 15:07:33 +01:00
Stig Telfer fd0ddca46c Add cleanup function for platform_event on BSD systems 2016-01-22 11:26:56 +00:00
Stig Telfer ec73c35952 Add missing C library headers 2016-01-22 11:08:13 +00:00
Joris Vink a958627837 Unlink correct file in upload example. 2016-01-20 10:33:32 +01:00
Joris Vink d67b5aaa04 Properly do config for upload example 2016-01-18 11:51:44 +01:00
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