Add matching capabilities to the Content-Type header #4950

Merged
merged 5 commits into from Aug 12, 2013

Projects

None yet

2 participants

@weierophinney
Member

This pull request adds the ability to match() a ContentType header against one or more mediatype specifications. As an example, for a Content-Type of "application/vnd.foo.v1.status+json", each of the following would successfully match:

  • */*
  • */*+* (essentially the same as above - full wildcard)
  • */*+json (wildcard, only matching mediatypes with the format "json")
  • */json (subtype matching format)
  • */vnd.foo.v1.*+* (partial subtype wildcard with wildcard format)
  • */vnd.foo.v1.*+json (partial subtype wildcard)
  • application/*
  • application/*+*
  • application/*+json
  • application/json
  • application/vnd.foo.v1.*+*
  • application/vnd.foo.v1.*+json
  • application/vnd.foo.v1.status+json
weierophinney added some commits Aug 12, 2013
@weierophinney weierophinney Added match capabilities to Content-Type header
- Allow specifying the mediatype and charset to the header.
- Allow specifying arbitrary parameters to the header.
- Update fromString() to inject mediatype and parameters.
- Added match() functionality similar to Accept header to allow matching
  one or more provided mediatypes against the given Content-Type header,
  including wildcard specifications.
7d95f75
@weierophinney weierophinney Additional unit tests
- Added more unit tests to ensure both matching and failure are
  represented
17e1d88
@weierophinney weierophinney Ensure passing multiple criteria works
- Return the matched criteria on success
- Only return from the loop if we validate; otherwise, delay returning a
  false value to the end of the method.
cd68cbc
@weierophinney weierophinney Update Response tests
- Header has a space between ';' delimiter and parameters
- Fix logic in ContentType header to ensure parameters are parsed and injected
  into the header.
23eda50
@weierophinney weierophinney Implement case-insensitive matching
- mediatype strings are supposed to be case-insensitive. Ensure
  mediatype is normalized to lowercase, and that comparison mediatypes
  are as well prior to matching.
0fdf89d
@Freeaqingme Freeaqingme merged commit 3138073 into zendframework:develop Aug 12, 2013

1 check passed

default The Travis CI build passed
Details
@weierophinney weierophinney added a commit to zfcampus/zf-content-negotiation that referenced this pull request Aug 15, 2013
@weierophinney weierophinney Add match()-aware Content-Type header
- Based on zendframework/zendframework#4950
- Registers the alternate Content-Type header implementation with each
  of the request and response objects.
409f4b9
@weierophinney weierophinney added a commit to zfcampus/zf-content-negotiation that referenced this pull request Aug 15, 2013
@weierophinney weierophinney Content-Type matching
- Ported final changes from zendframework/zendframework#4950
- Updated ContentTypeFilterListener to use new match() methodology from
  ContentType header
7f3f135
@weierophinney weierophinney added a commit to zfcampus/zf-content-negotiation that referenced this pull request Aug 15, 2013
@weierophinney weierophinney Removed custom ContentType header
- as zendframework/zendframework#4950 has been merged.
03cfe07
@gianarb gianarb pushed a commit to zendframework/zend-http that referenced this pull request May 15, 2015
@Freeaqingme Freeaqingme Merge pull request zendframework/zendframework#4950 from weierophinne…
…y/feature/content-type-header

Add matching capabilities to the Content-Type header
67c0313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment