1
0
mirror of https://git.kore.io/kore.git synced 2024-11-05 18:11:44 +01:00
Commit Graph

1292 Commits

Author SHA1 Message Date
Joris Vink
8b9ea825eb cookie improvements.
- split up writing of cookies into its own function.
- turn maxage into a signed int and use -1 for it not being set.
- lots of style fixes
- remove HTTP_COOKIE_DEFAULT, just pass 0 if you don't want flags.
2017-02-07 22:03:06 +01:00
Stanislav Yudin
f4ac8c2955 Cookies and arguments parsing improvements (#166)
Add new cookie API for handling of cookies.
2017-02-07 21:49:10 +01:00
Joris Vink
23d5e9b341 reword 2017-02-06 23:38:21 +01:00
Joris Vink
5a16bdbe65 whitespace 2017-02-06 22:53:09 +01:00
Joris Vink
f80a9cbc6c actually urldecode parameter names. 2017-02-06 22:47:32 +01:00
Joris Vink
604fae3a01 unfuck parsing http_body_max. 2017-02-06 21:28:33 +01:00
Joris Vink
c25c1c5281 pgsql: don't do a PQcancel() if it's not needed. 2017-02-06 20:01:16 +01:00
Joris Vink
09b0ae6d42 rename local sin to avoid potential conflicts. 2017-02-06 19:54:50 +01:00
Joris Vink
b8b8373702 when exiting clear any lingering python exceptions. 2017-02-06 16:54:38 +01:00
Joris Vink
21bf7f9583 rework base example a bit. 2017-02-06 12:21:40 +01:00
Joris Vink
01e3ef6cd3 no need to log ignored signals. 2017-02-06 12:13:34 +01:00
Joris Vink
6592eddcfb add stdint.h 2017-02-06 12:13:29 +01:00
Joris Vink
9f3046bae7 add README 2017-02-06 11:52:24 +01:00
Joris Vink
0bf36b763a add new python-pgsql example 2017-02-06 11:51:49 +01:00
Joris Vink
ace8c4e80c Add asynchronous pgsql query support to python.
This commit adds the ability to use python "await" to suspend
execution of your page handler until the query sent to postgresql
has returned a result.

This is built upon the existing asynchrous query framework Kore had.

With this you can now write stuff like:

async def page(req):
	result = await req.pgsql("db", "SELECT name FROM table");
	req.response(200, json.dumps(result).encode("utf-8"))

The above code will fire off a query and suspend itself so Kore can
take care of business as usual until the query is successful at which
point Kore will jump back into the handler and resume.

This does not use threading, it's purely based on Python's excellent
coroutines and generators and Kore its built-in pgsql support.
2017-02-06 11:42:53 +01:00
Joris Vink
80698ee40a add kore_mem_cleanup() to cleanup pools at exit. 2017-02-06 11:42:23 +01:00
Joris Vink
de7a6d4855 pgsql improvements.
- adds new cleanup function that workers will call.
- adds kore_pgsql_nfields() to return number of fields in result.
- add kore_pgsql_fieldname() to return name of a given field.

This commit also changes the behaviour of pgsql_conn_release() in
that it will now cancel the active query before releasing the connection.

This makes sure that if long running queries are active they are hopefully
cancelled if an http request is removed while such queries are still running.
2017-02-06 11:40:33 +01:00
Joris Vink
c3d2984939 fix parameters to kore_log(). 2017-02-06 11:39:50 +01:00
Joris Vink
76cb532de9 mark kore_log with printf attribute.
'bout time.
2017-02-06 11:39:30 +01:00
Joris Vink
d3f84db4b8 small fixes. 2017-02-01 21:36:53 +01:00
Joris Vink
7fb47da586 add http_file example to python example. 2017-02-01 21:35:44 +01:00
Joris Vink
6578fc6589 expose http_file interface to python. 2017-02-01 21:23:56 +01:00
Joris Vink
0250c8ecba style 2017-02-01 21:20:43 +01:00
Joris Vink
261fb3c3fa flesh out python example a bit more. 2017-02-01 17:15:18 +01:00
Joris Vink
3d8e0dabc0 expose kore_server_bind() and fatal() to python 2017-02-01 17:12:52 +01:00
Joris Vink
0c0a9371bd Change kore_preload() and kore_onload().
Renamed both of them:
	kore_preload -> kore_parent_configure
	kore_onload  -> kore_worker_configure

These functions will now always be called if they are defined in any module
regardless of your application being built as a single binary or not.
2017-02-01 17:12:11 +01:00
Joris Vink
8629419253 the example uses tls by default, so use it. 2017-01-31 09:21:06 +01:00
Joris Vink
bb9dbbec12 typo. 2017-01-30 22:47:41 +01:00
Joris Vink
6e7de9ab93 update python ws example. 2017-01-30 22:40:59 +01:00
Joris Vink
006f764d96 when getting OP_CLOSE disable reads. 2017-01-30 22:35:34 +01:00
Joris Vink
587a663f31 reorder ws disconnect order a bit. 2017-01-30 22:25:08 +01:00
Joris Vink
8b26ecdf14 more websocket improvements.
- send a CLOSE opcode if we haven't yet when removing a ws client.
- ignore unsolicited PONG.
2017-01-30 22:21:57 +01:00
Joris Vink
d5a32c2dab use the correct opcode for PONG.
djees i can't hex.
2017-01-30 22:17:47 +01:00
Joris Vink
30666618f8 expose kore_websocket_send() to python. 2017-01-30 22:00:03 +01:00
Joris Vink
e4d87b72a0 websocket improvements.
- properly send a CLOSE control frame back if the client sent us one.
- make sure we can send messages that are exactly USHRT_MAX bytes long.
2017-01-30 21:52:22 +01:00
Joris Vink
6bfba49ba5 cleanup data if required. 2017-01-30 21:50:36 +01:00
Joris Vink
f78e8f2fd2 allow None as source for kore.websocket_broadcast.
This allows kore.websocket_broadcast() to be used to relay the
messages back to all clients rather then all except the sender.
2017-01-30 21:48:58 +01:00
Joris Vink
6a43dd529c export WEBSOCKET_OP_TEXT and WEBSOCKET_OP_BINARY. 2017-01-30 21:02:58 +01:00
Joris Vink
3d3d705b98 flesh out the python stuff a bit more. 2017-01-30 20:47:24 +01:00
Joris Vink
7bc8bb42e2 implement kore_websockat_broadcast. 2017-01-30 20:30:42 +01:00
Joris Vink
5485967547 add websocket example to python 2017-01-29 22:57:55 +01:00
Joris Vink
7510834968 initial fudging to add websockets to python 2017-01-29 22:57:34 +01:00
Joris Vink
1ecb777d41 only remove the pgsql if it was scheduled.
fixes #172.
2017-01-29 10:34:53 +01:00
Joris Vink
829066dc23 i can't port. 2017-01-26 22:02:11 +01:00
Joris Vink
4940f97079 remove stuff that is not ready yet and add README. 2017-01-26 22:01:23 +01:00
Joris Vink
c06ecf1c70 Teach single binaries about SIGHUP.
Make sure kore_onload() and kore_preload() can be called
either in native or python runtime.
2017-01-26 13:26:55 +01:00
Joris Vink
3023ca0e57 Allow single binaries to load modules again. 2017-01-26 13:13:23 +01:00
Joris Vink
dcb5fd842f Expose get/post params via req.argument for python. 2017-01-26 12:01:28 +01:00
Joris Vink
1db3cd96d8 allow reloading of python modules on SIGHUP. 2017-01-26 11:13:09 +01:00
Joris Vink
2c66dfa3cf add python_import to example config 2017-01-25 22:43:59 +01:00