I think there is a better way to do that, here you're checking that it starts with the right content type, whereas you probably want to check this a bit differently.

According to the specification (http://pretty-rfc.herokuapp.com/RFC2616#header.accept) this is a bit trickier that what you seem to have implemented (unless I'm mistaken)