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

jsl-http_headers

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsl-http_headers

  • 0.0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= HttpHeaders

HttpHeaders is a library for parsing HTTP-compliant header strings. It was designed to process the results from the header_str method on Curl::Easy objects in Ruby, but should work for other HTTP-compliant string formats.

It correctly parses the content type, response code and most other key-value fields from the HTTP response header, including keys that may appear multiple times in the header such as Set-Cookie.

While parsing these header strings seems a very easy thing to do, the small variances in HTTP server responses make it more challenging to process these strings than it may initially appear. This library tries to account for these server variances by including a comprehensive test suite of HTTP header strings that the library has been tested against.

== Installation

Set up your machine to pull gems from gems.github.com if you haven't already. Then:

sudo gem install jsl-http_headers

== Quick Start

Just require the library, create a new HttpHeaders object with the header string and start invoking methods.

require 'http_headers' h = HttpHeaders.new(header_str) h.content_type h.etag h.set_cookie # Will return an Array of String values if more than one match is found

Other methods should just work for arbitrary attributes by lowercasing the attribute name and substituting hyphens with underscores.

== Implementation Notes

HttpHeaders uses ruby's +method_missing+ in order to build queries for the given parameter dynamically, so it doesn't need to parse values for every field at the time that the HttpHeader object is instantiated with a HTTP header string.

== Possible Limitations

Some attributes, such as Set-Cookie, may appear listed multiple times in the header. Where this occurs, we try to find all instances of the key and return an Array if multiple occurrences are found. Otherwise, nothing is done in the case where there are multiple values for a cookie given as values of a particular key - at this point the values won't be magically turned into an Array and it will be up to the user to program the desired behavior in a client library.

== Feedback

Please write the author if you have any questions or feedback about this library. Patches are welcome if you have ideas about how the behavior of HttpHeaders can be improved for particular cases. Please include specs using the associated test suite if you make improvements, and I would also be happy to receive more fixtures consisting of HTTP strings of failure cases indicating where the library can be improved.

== References

  • The HTTP Header Field Definitions - http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

== Author

Justin S. Leitgeb, justin@phq.org

FAQs

Package last updated on 11 Aug 2014

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