From 75cbbc2064bd33990a9fd03ee00cf9995b4a19c3 Mon Sep 17 00:00:00 2001 From: Nicolas Favre-Felix Date: Tue, 4 Jan 2011 21:46:39 +0100 Subject: [PATCH] Reworded Content-Type description. --- README.markdown | 51 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/README.markdown b/README.markdown index 7917186..30167c2 100644 --- a/README.markdown +++ b/README.markdown @@ -17,17 +17,15 @@ curl -d "GET/hello" http://127.0.0.1:7379/ # Features * GET and POST are supported. -* JSON output by default, optional JSONP parameter. -* Raw Redis 2.0 protocol output with `?format=raw` +* JSON output by default, optional JSONP parameter (`?jsonp=myFunction`). +* Raw Redis 2.0 protocol output with `.raw` suffix * HTTP 1.1 pipelining (50,000 http requests per second on a desktop Linux machine.) * Connects to Redis using a TCP or UNIX socket. * Restricted commands by IP range (CIDR subnet + mask) or HTTP Basic Auth, returning 403 errors. * Possible Redis authentication in the config file. * Pub/Sub using `Transfer-Encoding: chunked`, works with JSONP as well. Webdis can be used as a Comet server. * Drop privileges on startup. -* For `GET` commands: - * MIME type in a second key with `/GET/k?typeKey=type-k`. This will transform the `GET` request into `MGET` and fetch both `k` and `type-k`. If `type-k` is a string, it will be used as Content-Type in the response. If the key doesn't exist or isn't a string, `binary/octet-stream` is used instead. - * Custom MIME type with `?type=text/plain` (or any other MIME type). +* Custom Content-Type using a pre-defined file extension. * URL-encoded parameters for binary data or slashes. For instance, `%2f` is decoded as `/` but not used as a command separator. # Ideas, TODO... @@ -119,20 +117,20 @@ myCustomFunction({"TYPE":[true,"string"]}) # RAW output -This is the raw output of Redis; enable it with `?format=raw`. +This is the raw output of Redis; enable it with the `.raw` suffix.
 
 // string
-$ curl http://127.0.0.1:7379/GET/z?format=raw
+$ curl http://127.0.0.1:7379/GET/z.raw
 $5
 hello
 
 // number
-curl http://127.0.0.1:7379/INCR/a?format=raw
+curl http://127.0.0.1:7379/INCR/a.raw
 :2
 
 // list
-$ curl http://127.0.0.1:7379/LRANGE/x/0/-1?format=raw
+$ curl http://127.0.0.1:7379/LRANGE/x/0/-1?.raw
 *2
 $3
 abc
@@ -140,22 +138,24 @@ $3
 def
 
 // status
-$ curl http://127.0.0.1:7379/TYPE/y?format=raw
+$ curl http://127.0.0.1:7379/TYPE/y.raw
 +zset
 
 // error, which is basically a status
-$ curl http://127.0.0.1:7379/MAKE-ME-COFFEE?format=raw
+$ curl http://127.0.0.1:7379/MAKE-ME-COFFEE.raw
 -ERR unknown command 'MAKE-ME-COFFEE'
 
 
# Custom content-type -Webdis can serve `GET` requests with a custom content-type. There are two ways of doing this; the content-type can be in a key that is fetched with the content, or given as a query string parameter. - -**Content-Type in parameter:** +Several content-types are available: + * `.json` for `application/json` (this is the default Content-Type). + * `.txt` for `text/plain` + * `.html` for `text/html` + * `.png` for `image/png`
-curl -v "http://127.0.0.1:7379/GET/hello.html?type=text/html"
+curl -v "http://127.0.0.1:7379/GET/hello.html"	# the key is “hello” here, not “hello.html”
 [...]
 < HTTP/1.1 200 OK
 < Content-Type: text/html
@@ -168,24 +168,3 @@ curl -v "http://127.0.0.1:7379/GET/hello.html?type=text/html"
 </html>
 
-**Content-Type in a separate key:** - -
-curl "http://127.0.0.1:7379/SET/hello.type/text%2fhtml"
-{"SET":[true,"OK"]}
-
-curl "http://127.0.0.1:7379/GET/hello.type"
-{"GET":"text/html"}
-
-curl -v "http://127.0.0.1:7379/GET/hello.html?typeKey=hello.type"
-[...]
-< HTTP/1.1 200 OK
-< Content-Type: text/html
-< Date: Mon, 03 Jan 2011 20:56:43 GMT
-< Content-Length: 137
-<
-<!DOCTYPE html>
-<html>
-...
-</html>
-