New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-parser-lite

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-lite

  • 1.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

HTTP Parser Lite

A Lite™ wrapper around the Joyent http-parser goodness for Ruby

Install

gem install http-parser-lite

Example

parser = HTTP::Parser.new

parser.on_message_begin do
  puts "message begin"
end

parser.on_message_complete do
  puts "message complete"
end

parser.on_status_complete do
  puts "status complete"
end

parser.on_headers_complete do
  puts "headers complete"
end

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

parser.on_header_field do |name|
  puts "field: #{name}"
end

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

parser.on_body do |body|
  puts "body: #{body}"
end

parser << "HTTP/1.1 200 OK\r\n"
parser << "Content-Type: text/plain;charset=utf-8\r\n"
parser << "Content-Length: 5\r\n"
parser << "Connection: close\r\n\r\n"
parser << "hello"

parser.reset

parser << "GET http://www.google.com/ HTTP/1.1\r\n\r\n"

API

HTTP::Parser
    .new(type = HTTP::Parser::TYPE_BOTH)

    #reset(type = nil)
    #parse(data)
    #<<(data)

    #on_message_begin(&block)
    #on_message_complete(&block)
    #on_url(&block)
    #on_status_complete(&block)
    #on_header_field(&block)
    #on_header_value(&block)
    #on_headers_complete(&block)
    #on_body(&block)

    #http_status
    #http_method
    #http_version

    #pause
    #resume
    #paused?

    #error?
    #error

Constants:

* HTTP::Parser::TYPE_REQUEST
* HTTP::Parser::TYPE_RESPONSE
* HTTP::Parser::TYPE_BOTH

Exceptions:

* HTTP::Parser::Error

JRuby Support

Based on flyerhzm/http-parser.java, some code has been borrowed from http_parser.rb

License

MIT

FAQs

Package last updated on 03 Apr 2024

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