http_headers-content_type 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.idea/.rakeTasks +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +79 -78
- data/http_headers-content_type.gemspec +1 -1
- data/lib/http_headers/content_type.rb +1 -2
- data/lib/http_headers/content_type/version.rb +5 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6cd00370cb453e0185a30371c8d64dce1e34219d5c31c9b0d965682078ac74b5
|
|
4
|
+
data.tar.gz: 07ad48cc5aa6637500c88624ebfd03ec5b783bc43e7a0277cb7965fdd2481298
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82941c088ecb74557cab5528c6adeb90ba76f7909ef24216532ace7c7701ec39004809435ef8dbc8cbfcd2881dc59563d0a41b793611a771af90da8922d3b8f7
|
|
7
|
+
data.tar.gz: ea714ec1a949e91e7ae6d3dcb53cde30ab349779cd30258384dbc4365e9cbad137e6ab0b604965236bf1a26d6d8332f294480c5042f0c2fc7bb31ab64c435d65
|
data/.idea/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build http_headers-content_type-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install http_headers-content_type-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install http_headers-content_type-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push http_headers-content_type-0.1.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
# HttpHeaders::ContentType
|
|
2
|
-
|
|
3
|
-
[](https://travis-ci.com/XPBytes/http_headers-content_type)
|
|
4
|
-
[](https://badge.fury.io/rb/http_headers-content_type)
|
|
5
|
-
[](http://opensource.org/licenses/MIT)
|
|
6
|
-
|
|
7
|
-
:nut_and_bolt: Utility to parse and sort the "Content-Type" HTTP Header
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
Add this line to your application's Gemfile:
|
|
12
|
-
|
|
13
|
-
```ruby
|
|
14
|
-
gem 'http_headers-content_type'
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
And then execute:
|
|
18
|
-
|
|
19
|
-
$ bundle
|
|
20
|
-
|
|
21
|
-
Or install it yourself as:
|
|
22
|
-
|
|
23
|
-
$ gem install http_headers-content_type
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
You can parse the "Content-Type" header. As per the RFCs, you should really have one (delimited) value but the current
|
|
28
|
-
implementation accepts an array of values. Because there can only be one (1) `Content-Type` per request, it will always
|
|
29
|
-
pick the _last_ one, as per the RFCs.
|
|
30
|
-
|
|
31
|
-
```ruby
|
|
32
|
-
require 'http_headers/content_type'
|
|
33
|
-
|
|
34
|
-
parsed = HttpHeaders::ContentType.new('application/json; charset=utf-8')
|
|
35
|
-
parsed.to_s
|
|
36
|
-
# => 'application/json; charset=utf-8'
|
|
37
|
-
parsed.content_type
|
|
38
|
-
# => 'application/json'
|
|
39
|
-
parsed.charset
|
|
40
|
-
# => 'utf-8'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
parsed = HttpHeaders::ContentType.new([
|
|
44
|
-
'application/json; charset=utf-8',
|
|
45
|
-
'text/html; charset=utf-8; foo=bar'
|
|
46
|
-
])
|
|
47
|
-
parsed[:foo]
|
|
48
|
-
# => 'bar'
|
|
49
|
-
parsed.content_type
|
|
50
|
-
# => 'text/html'
|
|
51
|
-
parsed.charset
|
|
52
|
-
# => 'utf-8'
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Each parsed value exposes the following methods:
|
|
56
|
-
- `content_type`: the parsed content_type
|
|
57
|
-
- `charset`: the charset parameter as string, or nil
|
|
58
|
-
- `[](parameter)`: accessor for the parameter; throws if it does not exist
|
|
59
|
-
- `to_s`: encode back to an entry to be used in a `Content-Type` header
|
|
60
|
-
|
|
61
|
-
## Related
|
|
62
|
-
|
|
63
|
-
- [HttpHeaders::Utils](https://github.com/XPBytes/http_headers-utils): :nut_and_bolt: Utility belt for the HttpHeader libraries
|
|
64
|
-
- [HttpHeaders::Accept](https://github.com/XPBytes/http_headers-
|
|
65
|
-
- [HttpHeaders::AcceptLanguage](https://github.com/XPBytes/http_headers-accept_language): :nut_and_bolt: Utility to parse and sort the "Accept-Language" HTTP Header
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
# HttpHeaders::ContentType
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.com/XPBytes/http_headers-content_type)
|
|
4
|
+
[](https://badge.fury.io/rb/http_headers-content_type)
|
|
5
|
+
[](http://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
:nut_and_bolt: Utility to parse and sort the "Content-Type" HTTP Header
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'http_headers-content_type'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install http_headers-content_type
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
You can parse the "Content-Type" header. As per the RFCs, you should really have one (delimited) value but the current
|
|
28
|
+
implementation accepts an array of values. Because there can only be one (1) `Content-Type` per request, it will always
|
|
29
|
+
pick the _last_ one, as per the RFCs.
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
require 'http_headers/content_type'
|
|
33
|
+
|
|
34
|
+
parsed = HttpHeaders::ContentType.new('application/json; charset=utf-8')
|
|
35
|
+
parsed.to_s
|
|
36
|
+
# => 'application/json; charset=utf-8'
|
|
37
|
+
parsed.content_type
|
|
38
|
+
# => 'application/json'
|
|
39
|
+
parsed.charset
|
|
40
|
+
# => 'utf-8'
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
parsed = HttpHeaders::ContentType.new([
|
|
44
|
+
'application/json; charset=utf-8',
|
|
45
|
+
'text/html; charset=utf-8; foo=bar'
|
|
46
|
+
])
|
|
47
|
+
parsed[:foo]
|
|
48
|
+
# => 'bar'
|
|
49
|
+
parsed.content_type
|
|
50
|
+
# => 'text/html'
|
|
51
|
+
parsed.charset
|
|
52
|
+
# => 'utf-8'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Each parsed value exposes the following methods:
|
|
56
|
+
- `content_type`: the parsed content_type
|
|
57
|
+
- `charset`: the charset parameter as string, or nil
|
|
58
|
+
- `[](parameter)`: accessor for the parameter; throws if it does not exist
|
|
59
|
+
- `to_s`: encode back to an entry to be used in a `Content-Type` header
|
|
60
|
+
|
|
61
|
+
## Related
|
|
62
|
+
|
|
63
|
+
- [HttpHeaders::Utils](https://github.com/XPBytes/http_headers-utils): :nut_and_bolt: Utility belt for the HttpHeader libraries
|
|
64
|
+
- [HttpHeaders::Accept](https://github.com/XPBytes/http_headers-accept): :nut_and_bolt: Utility to parse and sort the "Accept" HTTP Header
|
|
65
|
+
- [HttpHeaders::AcceptLanguage](https://github.com/XPBytes/http_headers-accept_language): :nut_and_bolt: Utility to parse and sort the "Accept-Language" HTTP Header
|
|
66
|
+
- [HttpHeaders::Link](https://github.com/XPBytes/http_headers-link): :nut_and_bolt: Utility to parse and sort the "Link" HTTP Header
|
|
67
|
+
|
|
68
|
+
## Development
|
|
69
|
+
|
|
70
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
|
|
71
|
+
also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
72
|
+
|
|
73
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
|
74
|
+
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
|
|
75
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
76
|
+
|
|
77
|
+
## Contributing
|
|
78
|
+
|
|
79
|
+
Bug reports and pull requests are welcome on GitHub at [XPBytes/http_headers-content_type](https://github.com/XPBytes/http_headers-content_type).
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: http_headers-content_type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Derk-Jan Karrenbeld
|
|
@@ -80,6 +80,7 @@ extensions: []
|
|
|
80
80
|
extra_rdoc_files: []
|
|
81
81
|
files:
|
|
82
82
|
- ".gitignore"
|
|
83
|
+
- ".idea/.rakeTasks"
|
|
83
84
|
- ".idea/http_headers-content_type.iml"
|
|
84
85
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
|
85
86
|
- ".idea/misc.xml"
|
|
@@ -98,6 +99,7 @@ files:
|
|
|
98
99
|
- bin/setup
|
|
99
100
|
- http_headers-content_type.gemspec
|
|
100
101
|
- lib/http_headers/content_type.rb
|
|
102
|
+
- lib/http_headers/content_type/version.rb
|
|
101
103
|
homepage: https://github.com/XPBytes/http_headers-content_type
|
|
102
104
|
licenses:
|
|
103
105
|
- MIT
|