2个不稳定版本
0.2.0 | 2023年3月10日 |
---|---|
0.1.0 | 2023年3月10日 |
#848 in HTTP服务器
22KB
207 行
memoryhttpd
memoryhttpd是一个内存型HTTP服务器。可以通过PUT方法添加资源。它支持多个主机。
例如
$ curl -v https://127.0.0.1:3000/foo/bar/ -H Host:example.com -X PUT -d 'hello world'
> PUT /foo/bar/ HTTP/1.1
> Host:example.com
> Content-Length: 11
>
< HTTP/1.1 200 OK
< x-memoryhttpd-action: set
< content-length: 11
< date: Thu, 09 Mar 2023 20:32:07 GMT
<
hello world
$ curl -v https://127.0.0.1:3000/foo/bar/ -H Host:example.com
> GET /foo/bar/ HTTP/1.1
> Host:example.com
>
< HTTP/1.1 200 OK
< content-length: 11
< date: Thu, 09 Mar 2023 20:33:22 GMT
<
hello world
$ curl -v https://127.0.0.1:3000/foo/bar/ -H Host:example.net
> GET /foo/bar/ HTTP/1.1
> Host:example.net
> User-Agent: curl/7.85.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< content-length: 0
< date: Thu, 09 Mar 2023 20:33:28 GMT
<
命令
设置值
PUT /full/path HTTP/1.1
Host: hostname
Content-Length: 5
value
获取值
GET /full/path HTTP/1.1
Host: hostname
删除值
DELETE /full/path HTTP/1.1
Host: hostname
设置带有过期时间(以毫秒为单位)
PUT /full/path HTTP/1.1
Host: hostname
X-Expire-ms: 30000
Content-Length: 21
value expiring in 30s
用例
acme challenges
memoryhttpd可以用来存储临时令牌。例如,将其用作反向代理的/.well-known/acme-challenges/
的后端。
镜像
此仓库在以下位置镜像
依赖项
~5.5–8MB
~130K SLoC