use of org.n52.janmayen.http.MediaType in project arctic-sea by 52North.
the class MediaTypeTest method applicationXmlWithQAndVAndSpaces.
@Test
public void applicationXmlWithQAndVAndSpaces() {
MediaType mt = MediaType.parse(" application/xml; q=1; v=2 ");
errors.checkThat(mt.getType(), is("application"));
errors.checkThat(mt.getSubtype(), is("xml"));
errors.checkThat(mt.getParameters().size(), is(2));
errors.checkThat(mt.getParameter("q").iterator().next(), is("1"));
errors.checkThat(mt.getParameter("v").iterator().next(), is("2"));
}
use of org.n52.janmayen.http.MediaType in project arctic-sea by 52North.
the class MediaTypeTest method applicationXmlWithQAndSixSpace.
@Test
public void applicationXmlWithQAndSixSpace() {
MediaType mt = MediaType.parse(" application/xml; q=1 ");
errors.checkThat(mt.getType(), is("application"));
errors.checkThat(mt.getSubtype(), is("xml"));
errors.checkThat(mt.getParameters().size(), is(1));
errors.checkThat(mt.getParameter("q").iterator().next(), is("1"));
}
use of org.n52.janmayen.http.MediaType in project arctic-sea by 52North.
the class MediaTypeTest method applicationXmlWithQAndV.
@Test
public void applicationXmlWithQAndV() {
MediaType mt = MediaType.parse("application/xml;q=1;v=2");
errors.checkThat(mt.getType(), is("application"));
errors.checkThat(mt.getSubtype(), is("xml"));
errors.checkThat(mt.getParameters().size(), is(2));
errors.checkThat(mt.getParameter("q").iterator().next(), is("1"));
errors.checkThat(mt.getParameter("v").iterator().next(), is("2"));
}
use of org.n52.janmayen.http.MediaType in project arctic-sea by 52North.
the class MediaTypeTest method applicationXmlWithQuotedParameterAndSpaces.
@Test
public void applicationXmlWithQuotedParameterAndSpaces() {
MediaType mt = MediaType.parse(" application/xml; a=\"asdf\" ");
errors.checkThat(mt.getType(), is("application"));
errors.checkThat(mt.getSubtype(), is("xml"));
errors.checkThat(mt.getParameters().size(), is(1));
errors.checkThat(mt.getParameter("a").iterator().next(), is("asdf"));
}
use of org.n52.janmayen.http.MediaType in project arctic-sea by 52North.
the class SimpleBinding method writeOwsExceptionReport.
protected void writeOwsExceptionReport(HttpServletRequest request, HttpServletResponse response, OwsExceptionReport oer) throws HTTPException {
try {
this.eventBus.submit(new ExceptionEvent(oer));
MediaType contentType = chooseResponseContentTypeForExceptionReport(HTTPHeaders.getAcceptHeader(request), getDefaultContentType());
Object encoded = encodeOwsExceptionReport(oer, contentType);
if (isUseHttpResponseCodes() && oer.hasStatus()) {
response.setStatus(oer.getStatus().getCode());
}
httpUtils.writeObject(request, response, contentType, encoded, this);
} catch (IOException | OwsExceptionReport e) {
throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, e);
}
}
Aggregations