phoenixsol / lua-http-parser forked from ry/http-parser
- Source
- Commits
- Network (8)
- Downloads (3)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
LICENSE-MIT | Mon Nov 30 10:53:06 -0800 2009 | |
| |
Makefile | Mon Nov 30 10:53:06 -0800 2009 | |
| |
README.md | Wed Dec 09 06:09:54 -0800 2009 | |
| |
http_parser/ | Wed Dec 09 06:09:54 -0800 2009 | |
| |
lua_binding.c | Mon Nov 30 10:53:06 -0800 2009 | |
| |
test.lua | Mon Nov 30 10:59:49 -0800 2009 |
README.md
HTTP Parser
This is a parser for HTTP messages written in C. It parses both requests and responses. The parser is designed to be used in performance HTTP applications. It does not make any allocations, it does not buffer data, and it can be interrupted at anytime. It only requires about 136 bytes of data per message stream (in a web server that is per connection).
Features:
- No dependencies
- Parses both requests and responses.
- Handles persistent streams.
- Decodes chunked encoding.
- Extracts the following data from a message
- header fields and values
- content-length
- request method
- response status code
- transfer-encoding
- http version
- request path, query string, fragment
- message body
- Defends against buffer overflow attacks.
Lua Binding
Aims to be minimal and flexible; Allows setting of all parser callbacks from Lua.
local HTTPParser = require 'httpparser'
local parser = HTTPParser.new()
function parser.on_uri(data) print(data) end
function parser.on_path(data) print(data) end
parser:parse_request(request_data)
--parser:parse_response(response_data)
Return non-zero in the parser callbacks to stop the parser.
See 'test.lua' for a more complete example.
