Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-parser

  • 1.2.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

http-parser

Ruby FFI bindings to http-parser Build Status

Install

gem install http-parser

This gem will compile a local copy of http-parser

Usage

require 'rubygems'
require 'http-parser'

#
# Create a shared parser
#
parser = HttpParser::Parser.new do |parser|
  parser.on_message_begin do |inst|
    puts "message begin"
  end

  parser.on_message_complete do |inst|
    puts "message end"
  end

  parser.on_url do |inst, data|
    puts "url: #{data}"
  end

  parser.on_header_field do |inst, data|
    puts "field: #{data}"
  end

  parser.on_header_value do |inst, data|
    puts "value: #{data}"
  end
end

#
# Create state objects to track requests through the parser
#
request = HttpParser::Parser.new_instance do |inst|
  inst.type = :request
end

#
# Parse requests
#
parser.parse request, "GET /foo HTTP/1.1\r\n"
sleep 3
parser.parse request, "Host: example.com\r\n"
sleep 3
parser.parse request, "\r\n"

#
# Re-use the memory for another request
#
request.reset!

Acknowledgements

FAQs

Package last updated on 11 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc