Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby bindings to Ryan Dahl's http-parser
C Java Ruby
branch: master

This branch is 110 commits behind tmm1:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bench Remove trailing whitespace
lib use HTTP as the top-level module
spec Rename spec
.gitmodules Move sources into vendor so they are easier to compile against Use generic parser in readme example
Rakefile Update the specs for RSpec 2.0
ruby_http_parser.gemspec Remove trailing whitespace

Ruby bindings to Ryan Dahl's http-parser

Ruby bindings to


This gem aims to provide a simple Ruby HTTP parser API that can be used to build HTTP servers, clients and proxies. The gem will support all major Ruby platforms (JRuby, MRI 1.8 and 1.9, win32 and Rubinius).


require "http_parser"

parser =

parser.on_headers_complete = proc do |env|
  # Rack formatted env hash
  p env

parser.on_body = proc do |chunk|
  # One chunk of the body
  p chunk

parser.on_message_complete = proc do |env|
  # Headers and body is all parsed
  puts "Done!"

# Feed raw data from the socket to the parser
parser << raw_data
Something went wrong with that request. Please try again.