POST binary file

53 views
Skip to first unread message

Frédéric Logier

unread,
Mar 28, 2013, 7:10:41 PM3/28/13
to zer...@googlegroups.com
Hi,
I'm trying zerogw as an HTTP API server. So, I need to push some binary data with specific headers like this : 

curl -H "X-node-uuid: 2d0a7780-e8fe-4e0a-89c6-a5a2737b095a" -H "X-payload-filename: filename" -H "X-payload-type: filetype" -X POST --data-binary @myfile http://10.8.0.1:8000/echo

Is there a way to get from the zeromq worker these headers ? and is it possible to set a max data lengh ? because zerogw return this error : 2013-03-29 00:04:14 [WARN] http.c:380: Request size too big
I need to post data between 5ko to 200Mo.


Paul Colomiets

unread,
Mar 28, 2013, 8:08:18 PM3/28/13
to zer...@googlegroups.com
Hi Frédéric,


On Fri, Mar 29, 2013 at 1:10 AM, Frédéric Logier <fre...@gmail.com> wrote:
> Hi,
> I'm trying zerogw as an HTTP API server. So, I need to push some binary data
> with specific headers like this :
>
> curl -H "X-node-uuid: 2d0a7780-e8fe-4e0a-89c6-a5a2737b095a" -H
> "X-payload-filename: filename" -H "X-payload-type: filetype" -X POST
> --data-binary @myfile http://10.8.0.1:8000/echo
>
> Is there a way to get from the zeromq worker these headers ?

Yes. You should have something like the following in config:

zmq-forward:
enabled: yes
socket: !zmq.Req
- !zmq.Bind "ipc:///whatever/socket"
contents:
- !Uri
- !Header X-payload-type
- !Header X-payload-filename
- !Header X-node-uuid
- !Body


> and is it
> possible to set a max data lengh ? because zerogw return this error :
> 2013-03-29 00:04:14 [WARN] http.c:380: Request size too big
> I need to post data between 5ko to 200Mo.
>

Yes you can. The config follows:

Routing:
limits:
max-body-size: 200Mi

The limits are per route. You can write "limit" mapping at the same
level as "zmq-forward", to have bigger request limit only on certain
urls. "Mi" refer to Mebibytes (2**20), comparing to 1M which would be
1 million.

Note, request body is kept in memory until reply is fully sent, and no
streaming is performed.

You should probably limit number of simultaneous requests, to feel
safer from DoS attacks:

Server:
max-requests: 100

You are probably the first user who processes big file uploads, so
feel free to report any problems you have.

--
Paul

Frédéric Logier

unread,
Mar 28, 2013, 8:35:44 PM3/28/13
to zer...@googlegroups.com
Hi Paul,
it seems that zerogw is a great tools ! 
Anyway I didn't find in http://docs.zerogw.com/ some explain about the config file zerogw.yaml
By example, for an URI is it possible to know the HTTP method (GET, POST, PUT, DELETE) ?

Paul Colomiets

unread,
Mar 29, 2013, 4:15:39 AM3/29/13
to zer...@googlegroups.com
Hi Frédéric,

On Fri, Mar 29, 2013 at 2:35 AM, Frédéric Logier <fre...@gmail.com> wrote:
> Hi Paul,
> it seems that zerogw is a great tools !
> Anyway I didn't find in http://docs.zerogw.com/ some explain about the
> config file zerogw.yaml

Yes. That's a problem. The documentation should be much better. I'm
not sure I will find any time soon. But in the meantime there are
several options:

zerogw -P -- prints current configuration file with all the options
(including impicilty set ones)
zerogw -PP -- prints same with help string for each option
https://github.com/tailhook/zerogw/blob/master/src/config.yaml --
source for configuration file generator, you can find out options and
their types (for example what you are looking for is under
RequestField section)

And of course you can ask here :)

> By example, for an URI is it possible to know the HTTP method (GET, POST,
> PUT, DELETE) ?
>

Yes use "!Method"

--
Paul

Frédéric Logier

unread,
Mar 29, 2013, 4:45:49 AM3/29/13
to zer...@googlegroups.com
Hi Paul,
thanks for your help !


2013/3/29 Paul Colomiets <pa...@colomiets.name>

--
Paul

--
You received this message because you are subscribed to the Google Groups "Zerogw" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zerogw+un...@googlegroups.com.
To post to this group, send email to zer...@googlegroups.com.



--
http://fredix.wordpress.com
Reply all
Reply to author
Forward
0 new messages