Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Add matching capabilities to the Content-Type header #4950

Merged

Conversation

weierophinney
Copy link
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

- 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.
- Added more unit tests to ensure both matching and failure are
  represented
- 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.
- Header has a space between ';' delimiter and parameters
- Fix logic in ContentType header to ensure parameters are parsed and injected
  into the header.
- mediatype strings are supposed to be case-insensitive. Ensure
  mediatype is normalized to lowercase, and that comparison mediatypes
  are as well prior to matching.
Freeaqingme added a commit that referenced this pull request Aug 12, 2013
Add matching capabilities to the Content-Type header
@Freeaqingme Freeaqingme merged commit 3138073 into zendframework:develop Aug 12, 2013
weierophinney added a commit to zfcampus/zf-content-negotiation that referenced this pull request Aug 15, 2013
- Based on zendframework/zendframework#4950
- Registers the alternate Content-Type header implementation with each
  of the request and response objects.
weierophinney added a commit to zfcampus/zf-content-negotiation that referenced this pull request Aug 15, 2013
- Ported final changes from zendframework/zendframework#4950
- Updated ContentTypeFilterListener to use new match() methodology from
  ContentType header
weierophinney added a commit to zfcampus/zf-content-negotiation that referenced this pull request Aug 15, 2013
gianarb pushed a commit to zendframework/zend-http that referenced this pull request May 15, 2015
…y/feature/content-type-header

Add matching capabilities to the Content-Type header
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants