http-accept 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 409b179f21a3c570060f5d16802137a640c997e0
4
- data.tar.gz: 93108cf6d8302906d14f1e0e979e990721e733a7
3
+ metadata.gz: 954845d60bf94eee8063d94cd3e848d9fa551464
4
+ data.tar.gz: 7a82a3455fdd4a2dd6de9fcc973750aa3be5cd12
5
5
  SHA512:
6
- metadata.gz: 2c154231b09a91b992b3f6bb1fabb092782f19bcc11fcaed933adf9682632a9e28a31e438447dc5284635c346e25b0a97b8f74a7ad771ffa64addf305bf5d098
7
- data.tar.gz: aeab4528e8ebf4ad756a95059ceaaeea3ad357d350a80b2f147b9c8f20ebb3c3500a8c6e9e94bb74e9774823ae39e36abcd3317d7c9e95c0816799d302b788f6
6
+ metadata.gz: 5746efff959b201d04f83725d00c103c71f9a5dad69b33d7ee765b8b23f68b947fb9d61aac11faa08d25ac857280fb131d7595a38d5a74dce73bcf853f58aaee
7
+ data.tar.gz: 4cd56d9c300498ad2ddaa6534fa011b955a395f5632c9162f533ddaa2f27923a8d0901dd96ded80013c75269d3862218205c7eda9a43fec8b63b280cbdee24ae
data/README.md CHANGED
@@ -8,6 +8,14 @@ Current `Accept-Encoding:` and `Accept-Charset:` are not supported. This is beca
8
8
  [![Code Climate](https://codeclimate.com/github/ioquatix/http-accept.svg)](https://codeclimate.com/github/ioquatix/http-accept)
9
9
  [![Coverage Status](https://coveralls.io/repos/ioquatix/http-accept/badge.svg)](https://coveralls.io/r/ioquatix/http-accept)
10
10
 
11
+ ## Motivation
12
+
13
+ I've been [developing some tools for building RESTful endpoints](https://github.com/ioquatix/utopia/blob/master/lib/utopia/controller/respond.rb) and part of that involved versioning. After reviewing the options, I settled on using the `Accept: application/json;version=1` method [as outlined here](http://labs.qandidate.com/blog/2014/10/16/using-the-accept-header-to-version-your-api/).
14
+
15
+ The `version=1` part of the `media-type` is a `parameter` as defined by [RFC7231 Section 3.1.1.1](https://tools.ietf.org/html/rfc7231#section-3.1.1.1). After reviewing several existing different options for parsing the `Accept:` header, I noticed a disturbing trend: `header.split(',')`. Because parameters may contain quoted strings which contain commas, this is clearly not an appropriate way to parse the header.
16
+
17
+ I am concerned about correctness, security and performance. As such, I implemented this gem to provide a simple high level interface for both parsing and correctly interpreting these headers.
18
+
11
19
  ## Installation
12
20
 
13
21
  Add this line to your application's Gemfile:
@@ -26,7 +26,8 @@ require_relative 'sort'
26
26
  module HTTP
27
27
  module Accept
28
28
  module Languages
29
- LOCALE = /\*|[A-Z]{1,8}(-[A-Z]{1,8})*/i
29
+ # https://tools.ietf.org/html/rfc3066#section-2.1
30
+ LOCALE = /\*|[A-Z]{1,8}(-[A-Z0-9]{1,8})*/i
30
31
 
31
32
  # https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.9
32
33
  QVALUE = /0(\.[0-9]{0,3})?|1(\.[0]{0,3})?/
@@ -20,6 +20,6 @@
20
20
 
21
21
  module HTTP
22
22
  module Accept
23
- VERSION = "1.1.0"
23
+ VERSION = "1.1.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-accept
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams