184 Commits

Author SHA1 Message Date
Joris Vink
92b4225814 add memory tag example 2017-08-30 11:50:02 +02:00
bhesmans
a2d78179a4 Small fix in video stream example (#195) 2017-06-25 11:46:32 +02:00
Joris Vink
19b7f75b90 change up a comment that is wrong. 2017-06-01 10:10:54 +02:00
Joris Vink
a3ed3bf7eb Convert pgsql-sync example after pgsql changes.
Only check if we bound something if we're asynchronous.
2017-03-24 13:00:05 +01:00
Joris Vink
59f7e85f45 Decouple pgsql from the http layer.
When the pgsql layer was introduced it was tightly coupled with the
http layer in order to make async work fluently.

The time has come to split these up and follow the same method we
used for tasks, allowing either http requests to be tied to a pgsql
data structure or a simple callback function.

This also reworks the internal queueing of pgsql requests until
connections to the db are available again.

The following API functions were changes:
	- kore_pgsql_query_init() -> kore_pgsql_setup()
		no longer takes an http_request parameter.
	- NEW kore_pgsql_init()
		must be called before operating on an kore_pgsql structure.
	- NEW kore_pgsql_bind_request()
		binds an http_request to a kore_pgsql data structure.
	- NEW kore_pgsql_bind_callback()
		binds a callback to a kore_pgsql data structure.

With all of this you can now build kore with PGSQL=1 NOHTTP=1.

The pgsql/ example has been updated to reflect these changes and
new features.
2017-03-24 12:53:07 +01:00
Joris Vink
3b5d4a2b03 update example 2017-03-13 13:31:36 +01:00
Joris Vink
3ae9bb7ae9 change type of maxage. 2017-03-10 14:36:51 +01:00
Joris Vink
4db51d7846 screw it, rework interface for cookies.
The only reason you would want to directly modify the cookie
after creating it should be to unset the HTTPONLY or SECURE flags
if that is what you *really* want to do.

Change http_response_cookie() to take all required parameters instead
of having to marshall those in yourself after.

Now you set a sane default cookie in one shot:

http_response_cookie(req, "key", "value", "/", 0, -1, NULL);

Which would create a session cookie key=value for / under the current domain.
2017-03-10 14:31:08 +01:00
Joris Vink
3d24b65268 Change default http_cookie behaviour.
We now default to httponly & secure for newly created cookies.

This should've been the default all along.

The http_response_cookie() no longer returns a pointer to http_cookie
but rather takes it as a parameter and will populate the pointer with
the newly created http_cookie if not NULL.

Additionally http_response_cookie() automatically sets the domain
based on the http_request passed into the function.
2017-03-10 14:20:40 +01:00
Joris Vink
edd7a10773 move static assets to use asset_serve_* in generic.
note that certain browsers change their caching behaviour when you
are connecting over TLS using self-signed certificates.

reminded by #179
2017-03-08 10:20:53 +01:00
Joris Vink
175b2e2c9b kore flavor -> kodev flavor 2017-03-06 23:18:16 +01:00
Joris Vink
f1d33ab91b kore -> kodev where appropriate 2017-03-06 11:00:53 +01:00
Joris Vink
3e84502235 Adjust examples after recent changes.
- New kodev tool generates config with server.pem/key.pem.
- Use proper formats for kore_log().
- Update to new websocket api.
2017-02-25 17:02:39 -08:00
Joris Vink
e9b4f966c2 expose new cookie stuff to python.
req.populate_cookies()
value = req.cookie("name")
2017-02-07 22:54:42 +01:00
Joris Vink
7c78dea211 more cookie example improvements.
- remove unneed headers.
- rename local to avoid shadowing.
2017-02-07 22:12:56 +01:00
Joris Vink
4e556dbd8f rename example cookies source file. 2017-02-07 22:06:31 +01:00
Joris Vink
36e99072f3 cookie example improvements. 2017-02-07 22:04:00 +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
21bf7f9583 rework base example a bit. 2017-02-06 12:21:40 +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
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
261fb3c3fa flesh out python example a bit more. 2017-02-01 17:15:18 +01:00
Joris Vink
8629419253 the example uses tls by default, so use it. 2017-01-31 09:21:06 +01:00
Joris Vink
6e7de9ab93 update python ws example. 2017-01-30 22:40:59 +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
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
ef441fb9a1 bah, be gone. 2017-01-25 22:38:43 +01:00
Joris Vink
ff48aed926 initial python example.
don't look too much into this yet.
2017-01-25 22:38:06 +01:00
Yorick de Wid
86d85dd10b Message shutdown request (#168)
* Set server version

* Message shutdown request

* Update messaging example

* Set server verion in generic example

* Allow shutdown with NOHTTP=1
2017-01-17 18:18:01 +01:00
john721
f15558ed98 Fix no response in case kore was built with NOTLS=1. (#142) 2016-08-16 10:19:07 +02:00
Raphaël Monrouzeau
32ac27d4c3 JSONRPC Reverted explicit deallocation calls
The possibility to call jsonrpc_destroy_request was left. Someone may
want to abruptly interrupt the process of its request for some odd
reason, in that case an exlicit call still would be to be made.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau
016dc27346 JSONRPC Made request destruction explicit
Caller has now to destroy jsonrpc_request after use. This permits them
to read / inspect it after having responded.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau
8c78b28be3 JSONRPC Removed upload size limit check
A true application dependant limit check would require stream parsing.
As the limit enforcement was done, it added nothing of value compared
to HTTP request limit check, which is in Kore already.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau
3366ec6573 Required params to be structured as per spec 2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau
4ffe43cf87 Compliantly don't return anything to notifications
And don't return anything either if protocol doesn't match.
2016-07-15 13:08:08 +02:00
Raphaël Monrouzeau
db02e990ea JSON-RPC support for Kore.
The API surface is very limited. Jsonrpc support reads request from HTTP
body and such can't be activated if NOHTTP=1. At the moment there is no
websocket support either (which is a shame). It depends upon the
third-party Yajl library.

Errors can be emitted using jsonrpc_error() and results using
jsonrpc_result(), for the later you'll have to provide a callback which
will write the inner of the result object.

If errors happen during the response write process, no further error
output will be attempted and an HTTP error 500 will be returned.

Read the provided example for getting a better idea of the API.
2016-07-15 13:08:08 +02:00
Joris Vink
43fec8678e kore_buf_create -> kore_buf_alloc. 2016-07-14 12:34:29 +02:00
Joris Vink
4ad50caa29 Large changes to the memory subsystem in kore.
- Change pools to use mmap() for allocating regions.
- Change kore_malloc() to use pools for commonly sized objects.
  (split into multiple of 2 buckets, starting at 8 bytes up to 8192).
- Rename kore_mem_free() to kore_free().

The preallocated pools will hold up to 128K of elements per block size.

In case a larger object is to be allocated kore_malloc() will use
malloc() instead.
2016-07-12 13:54:14 +02:00
Joris Vink
d30921103b Code cleanup, several API breaking changes in here 2016-07-08 10:03:41 +02:00
Joris Vink
7ac1ea379d Unbreak json_yajl example. 2016-07-06 09:23:41 +02:00
Corbin Hughes
698b3f374f Compile and link C++ with g++ instead of gcc 2016-06-26 15:49:59 -05:00
Joris Vink
4503b4756b remove lies. 2016-02-13 15:38:00 +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