Skip to content

My fork of redis which operates over HTTP instead of RESP

License

Notifications You must be signed in to change notification settings

mac-chaffee/redis-over-http

 
 

Repository files navigation

Redis over HTTP

This repo contains a fork of redis that can be accessed directly by a web browser using HTTP.

Redis normally executes commands by parsing its own protocal called RESP: https://redis.io/topics/protocol

But the protocol also support "Inline Commands", which look like this:

GET somekey
SET somekey somevalue

This just so happens to be close enough to HTTP:

GET /somekey HTTP/1.1

By modifying how Redis processes requests and generated responses, we can turn RESP into HTTP.

Development

This repo is forked from Redis 6.0, then http-redis.patch is applied. Then you can build and test the code with:

cd src
make
./redis-server ../redis.conf
  • To test a GET command: curl -i localhost:6379/mykey
  • To test a SET command: curl -iX SET "localhost:6379/mykey \"somevalue\""
  • To run administrative commands, ./redis-cli still works since the HTTP code only affects use of the "inline" protocol.

All other supported commands can be constructed similarly.

The contents of homepage.html are accessed by the key "/", which cannot be modified.

Deployment

./deploy.sh

ACLs

I use ACLs (new in redis 6.0) to prevent anonymous users from running dangerous commands. These ACLs can be found on line 765 of redis.conf.

Limitations

Requests sizes are limited to 16128 bytes to simplify buffer handling since I'm not exactly an expert in C code.

Several commands have been disabled for security reasons (like obviously SHUTDOWN).

About

My fork of redis which operates over HTTP instead of RESP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 84.5%
  • Tcl 13.5%
  • Objective-C 0.6%
  • Shell 0.4%
  • Ruby 0.4%
  • Makefile 0.3%
  • Other 0.3%