Skip to content

Instantly share code, notes, and snippets.

@need12648430
Created June 21, 2014 08:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save need12648430/0fb5825c4268b988166e to your computer and use it in GitHub Desktop.
Save need12648430/0fb5825c4268b988166e to your computer and use it in GitHub Desktop.
HTTP requests parsed in 4 lines of Lua.
local verb, resource, version, headers, body = data:match("(.+)%s+(.+)%s+(HTTP/%d%.?%d?)\r\n(.-)\r\n\r\n(.-)")
headers:gsub("(.-)%s*:%s*(.-)\r\n", function(name, value)
-- do something with name and value here
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment