Commit Graph

196 Commits

Author SHA1 Message Date
Joris Vink be96a93f9e Add missing ssl_dhparam to all example configs. 2015-02-06 09:02:29 +01:00
Joris Vink 1a680d8d09 Remove lingering diff file 2014-11-24 11:09:19 +01:00
Joris Vink f867882f43 Add websocket support to Kore.
Introduces a few new api functions:

- kore_websocket_handshake(struct http_request *):
	Performs the handshake on an HTTP request (coming from page handler)

- kore_websocket_send(struct connection *, u_int8_t, void *, size_t):
	Sends data to a websocket connection.

- kore_websocket_broadcast(struct connection *, u_int8_t, void *, size_t, int):
	Broadcast the given websocket op and data to all connected
	websocket clients on the worker. Note that as of right now
	the WEBSOCKET_BROADCAST_GLOBAL scope option does not work
	yet and messages broadcasted will be restricted to workers
	only.

- kore_worker_websocket_broadcast(struct connection *, void *, void *):
	Backend function used by kore_websocket_broadcast().
	Could prove useful for developers to have access to.

A simple example is given under examples/websocket.

Known issues:
	Kore does not support PING or CONT frames just yet.
2014-11-24 11:08:34 +01:00
Joris Vink ac4222e929 Proper use of kore_strtonum64(). 2014-11-24 10:39:38 +01:00
Joris Vink a4d50d3ddf Remove the my_callback example. Deprecated. 2014-10-31 10:14:47 +01:00
Joris Vink b1797231cc Properly error out in HTML5 video streaming. 2014-10-31 10:13:45 +01:00
Joris Vink 6de0f8568a Rework net, worker and some http internals.
- The net code no longer has a recv_queue, instead reuse same recv buffer.
- Introduce net_recv_reset() to reset the recv buffer when needed.
- Have the workers spread the load better between them by slightly
  delaying their next accept lock and giving them an accept treshold
  so they don't go ahead and keep accepting connections if they end
  up winning the race constantly between the workers.
- The kore_worker_acceptlock_release() is no longer available.

- Prepopulate the HTTP server response header that is added to each
  response in both normal HTTP and SPDY modes.
- The path and host members of http_request are now allocated on the heap.

These changes overall result better performance on a multicore machine,
especially the worker load changes shine through.
2014-10-22 21:16:49 +02:00
Joris Vink 0e8bdf38c4 Indenting police 2014-10-22 20:50:32 +02:00
Joris Vink 0d17d2228c Bring ktunnel example client in line with reality 2014-10-22 19:00:48 +02:00
Joris Vink ffe94ff585 KORE_LDFLAGS is no more. 2014-10-22 18:48:43 +02:00
Joris Vink b9445e84ca Use the right ssl_ctx 2014-10-22 18:44:31 +02:00
Joris Vink 81bc889abc Make ktunnel example tls1.2 only 2014-10-22 08:36:50 +02:00
Joris Vink a603b77e24 Add PUT/DELETE/HEAD methods (finally).
This commit renames certain POST centric variable and configuration
naming to the correct HTTP body stuff.

API changes include http_postbody_text() and http_postbody_bytes() to
have become http_body_text() and http_body_bytes().

The developer is still responsible for validating the method their
page handler is called with. Hopefully this becomes a configuration
option soon enough.
2014-10-08 11:03:14 +02:00
Joris Vink 626206f0d8 Set idle_timer.length in ktunnel to a high number.
This makes my tunnels not timeout every 20 seconds, much nicer.
2014-09-29 14:47:01 +02:00
Joris Vink 3b09683f5c Add kore_pgsql_query_params().
This function uses PQsendQueryParams() instead of the normal PQsendQuery()
allowing you to pass binary data in a cleaner fashion.

A basic call would look something like:

char *mydata = "Hello";
size_t mydata_len = strlen(mydata);

kore_pgsql_query_params(&pgsql, req,
    "INSERT INTO foo VALUES($1::text)", KORE_PGSQL_FORMAT_TEXT, 1
    mydata, mydata_len, KORE_PGSQL_FORMAT_TEXT);

kore_pgsql_query_params() is variadic, allowing you to pass any
count of parameters where each parameter has the following:
	data pointer, data length, type of parameter.
2014-09-28 21:39:16 +02:00
Joris Vink e3417dea16 Remove the pgsql simple layer again.
I rather keep the old idioms instead of adding more complex things
on top of the async ones. Especially since the simple layer would
interfear with existing http state machines from your handler.
2014-09-19 15:53:22 +02:00
Joris Vink eef40bf2dd add a .gitignore here 2014-09-19 14:51:14 +02:00
Joris Vink c4c60e1960 Oops, make sure the new simple api can handle > 1 request without borking. 2014-09-19 14:49:12 +02:00
Joris Vink 8e9c3da764 Add a new "simple query" layer to our pgsql api.
This simple query allows you to ditch rolling your own
state machine for handling async pgsql states and instead
asks you to provide 3 functions:
	- init
	- results
	- done

You can see the different in complexity in the pgsql example,
which now contains a pgsql_simple.c holding the same asynchronous
query as in pgsql.c but using the simple pgsql api.

You can of course still roll your own in case you want more control.
2014-09-19 12:32:49 +02:00
Joris Vink 0e11edefb5 s/HTTP_STATUS_RETRY/HTTP_STATE_RETRY 2014-09-19 11:16:56 +02:00
Joris Vink 8982a7b3c9 Disable timeouts for ktunnel 2014-09-18 10:30:59 +02:00
Joris Vink 34d146fc01 Fix ktunnel compilation under BSDs 2014-09-18 09:52:48 +02:00
Joris Vink c5f00d3443 Add KTunnel example, an anything-over-HTTPS tunnel using Kore. 2014-09-17 08:53:13 +02:00
Joris Vink 6e6b042388 Add KORE_PGSQL_STATE_WAIT to our example 2014-08-15 12:39:31 +02:00
Joris Vink 8565b47800 Attach tasks/pgsqls to http_requests once more.
This way if an http request is removed while tasks or
pgsqls are still active they are free'd out and cancelled
properly.
2014-08-14 22:05:34 +02:00
Joris Vink 0b3c918ba6 Properly check for connection trouble in the pgsql example 2014-08-14 15:13:47 +02:00
Joris Vink f93747828c Major pgsql rework.
Gone is the ugly KORE_PGSQL macro that hid an overly complex
state machine for the pgsql api.
Gone is the pgsql array that was attached to http_requests.
Gone are the callback hacks inside the pgsql api.

Instead, I strongly encourage people to use the new state machine
api Kore offers to properly deal with asynchronous queries.

The pgsql example in examples/pgsql has been updated to reflect
these changes.
2014-08-14 14:34:23 +02:00
Joris Vink e0cdc31c73 Take away the reference to the video if we're not streaming 2014-08-12 09:43:19 +02:00
Joris Vink 7349fab13f Sprinkle kore_snprintf() where appropriate. 2014-08-11 11:02:30 +02:00
Joris Vink 70d9df8896 s/id/user 2014-08-11 11:01:59 +02:00
Joris Vink 1616320490 Add an html5 video streaming example 2014-08-10 19:33:43 +02:00
Joris Vink 966ed3d20d Rename the two functions used to read/set headers.
Rename http_request_header_get() to http_request_header().
Rename http_response_header_add() to http_response_header().
2014-08-05 14:26:31 +02:00
Joris Vink b27322933b The default pid file is kore.pid so no need to set that explicitely 2014-08-05 13:11:53 +02:00
Joris Vink 577462379d Deprecate ssl_no_compression config option, its always on. 2014-08-05 13:07:32 +02:00
Joris Vink 79a736fc16 Add a link to yajl repo 2014-08-04 21:06:35 +02:00
Joris Vink 0c5b0d2288 Add an example that parses JSON via yajl 2014-08-04 21:06:02 +02:00
Joris Vink 9dbcf5399f Add headers example 2014-08-04 20:06:59 +02:00
Joris Vink b3f65ae13f Add a readme to parameters + update some text 2014-08-04 19:02:23 +02:00
Joris Vink 4a7653f195 Add a parameters example.
This example shows how the parameter system in Kore works
and how to use it properly.
2014-08-04 19:00:25 +02:00
Joris Vink d35bb9837d update comment in example tasks.c 2014-08-03 21:47:19 +02:00
Joris Vink 850e39fcfb Add more READMEs 2014-08-03 21:44:14 +02:00
Joris Vink 5c21a120fc s/hello-world/integers 2014-08-03 20:31:40 +02:00
Joris Vink 8f523ecf0c Alter readme a bit 2014-08-03 20:30:39 +02:00
Joris Vink 9cba130c4b Add integers example 2014-08-03 20:29:24 +02:00
Joris Vink 55b344f1c3 Redo last move, but properly this time 2014-08-03 17:47:29 +02:00
Joris Vink 93fa404470 Move contrib/examples into examples 2014-08-03 17:45:23 +02:00