
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
= 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
gem install 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
== Author
Justin S. Leitgeb, justin@stackbuilders.com
Copyright (c) 2010 {Stack Builders Inc.}[http://stackbuilders.com]
FAQs
Unknown package
We found that http_headers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.