https://github.com/ademdc/parse-http
HTTP parser for Ruby
https://github.com/ademdc/parse-http
http parser restclient
Last synced: 3 months ago
JSON representation
HTTP parser for Ruby
- Host: GitHub
- URL: https://github.com/ademdc/parse-http
- Owner: ademdc
- Created: 2021-12-07T19:39:06.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-12T15:42:00.000Z (over 3 years ago)
- Last Synced: 2025-01-13T04:27:55.863Z (4 months ago)
- Topics: http, parser, restclient
- Language: Ruby
- Homepage: https://rubygems.org/gems/parse-http
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# parse-http
Ruby HTTP parser## Installation
Add this line to your application's Gemfile:```
gem 'parse-http', '1.0.1', require: 'parse-http'
```...followed with:
```
bundle install
```Or install it with:
```
gem install parse-http
```## Usage
```
uri = URI.parse('www.example.com')
response = Net::HTTP.get_response(uri)
parser = HttpParser.parse(response)
```The `parser` object is a Struct which has two parameters: `success?` and `hash_response`. e.g.
```
#1, "id"=>1, "title"=>"delectus aut autem", "completed"=>false}>
```The requirment for the response which is passed to the initializier is to have the `conent-type: application/json`
So far, it works with `Net::HTTTP` and `RestClient`.
## Run tests
```
rspec spec
```### Thank you for using HttpParser!