I’ve been working a lot on JSON APIs during the past few years, and even more intensively lately. If testing GET requests is straightforward, for POST requests I often had to look at Curl documentation again for exact options names and parameter syntax for sending the desired HTTP headers.
So I decided to post some quick notes on doing unauthenticated POST requests, in order to have a quickly accessible reference.
Here is a list of some relevant Curl options :
-d, --dataDATA HTTP POST data (H)
-X, --request COMMAND Specify request command to use
-H, --header LINE Custom headerto pass to server (H)
Doing an empty POST request
curl --request POST http://127.0.0.1:8080/api/store
Specifying the package option when invoking make will create a binary package in /usr/pkgsrc/packages/All. As compiling can take a long time on the Pi, this is especially handy when doing reinstalls or using multiple boards.
Here is the list of packages which have been created :
So far, running NetBSD on the Raspberry Pi has been a very positive experience and the system is very stable. I would definitely recommend anyone wanting to use BSD on the Pi to give NetBSD a try, it’s well worth it.
I should probably also mention that it’s smaller than a toaster :-)
Server Side Includes are an interesting way to embed content dynamically into static files. It can be particularly useful to inject information about the visitor or to add headers, footers or any file containing data changing over time.
Please note, however, that Nginx does not implement the full SSI specification yet. More information about what is currently supported can be found in the ngx_http_ssi_module documentation.
To enable SSI, the following directive must be added in the http, server or location block :
Here is an example HTML snippet with SSI directives, showing how to echo variables and include content from other files :
In order to populate fortune.txt and uptime.txt, we can use Cron and refresh files content as required. For even more fun, we can also use cowsay together with fortune.
Finally, here is the resulting output when accessing the page using Lynx :
Visitor IP address : 184.108.40.206
Visitor User agent : Lynx/2.8.8rel.2 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/1.0.1h
Server local time : Sunday, 21-Sep-2014 18:55:49 CEST
Server time (GMT) : Sunday, 21-Sep-2014 16:55:49 GMT
Server uptime : 18:55:01 up 52 days, 7:50, 3 users, load average: 0.13, 0.19, 0.22
Fortune of the day
/ In most countries selling harmful \
| things like drugs is punishable. Then |
| howcome people can sell Microsoft |
| software and go unpunished? |
\ -- Hasse Skrifvars, firstname.lastname@example.org, /
// \ \
(| | )
Most of the time, there is no need to compile Nginx manually as Debian and Ubuntu provide several packages being compiled with a different set of modules (for details, see : Nginx packages in Debian stable). However, when performing more specific testing tasks, I sometimes need an exact particular version and have to compile it manually.
So here are the required steps to build Nginx with SSL and SPDY modules enabled.
Since I’ve been more and more interested about NetBSD lately, I decided to draw some ASCII logos to be used as MOTD and/or as /etc/issue. So here are the two variants I came up with, rendered with Amiga Topaz font.
Feel free to use them on your systems, and change the NetBSD port in the information boxes accordingly. I currently use mainly NetBSD/evbarm, so the logos reflect that.