From 9ddc88582e3a1b1d829d3c4864b51ec347208d99 Mon Sep 17 00:00:00 2001 From: Patrick Huang Date: Thu, 16 Jun 2016 14:54:27 +1000 Subject: [PATCH] ZNTA-1178 - fix issue pulling file type project --- .../org/zanata/rest/client/InvalidContentTypeFilter.java | 4 ++-- .../zanata/rest/client/InvalidContentTypeFilterTest.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/zanata-rest-client/src/main/java/org/zanata/rest/client/InvalidContentTypeFilter.java b/zanata-rest-client/src/main/java/org/zanata/rest/client/InvalidContentTypeFilter.java index 273e2ada..780f0a19 100644 --- a/zanata-rest-client/src/main/java/org/zanata/rest/client/InvalidContentTypeFilter.java +++ b/zanata-rest-client/src/main/java/org/zanata/rest/client/InvalidContentTypeFilter.java @@ -50,9 +50,9 @@ public class InvalidContentTypeFilter extends ClientFilter { "Please check the server URL is correct (in zanata.ini and in zanata.xml) and make sure you use the correct address."; - // we assume only xml or json are the valid types (wildcard type is also considered compatible) + // we assume application/* are all the valid types (wildcard type is also considered compatible) private static final Pattern VALID_TYPES_REGEX = - Pattern.compile("application/.*\\+?(\\*|xml|json)(;.*)?"); + Pattern.compile("application/.*"); @Override public ClientResponse handle(ClientRequest clientRequest) diff --git a/zanata-rest-client/src/test/java/org/zanata/rest/client/InvalidContentTypeFilterTest.java b/zanata-rest-client/src/test/java/org/zanata/rest/client/InvalidContentTypeFilterTest.java index 4de1f1ab..10e3dba2 100644 --- a/zanata-rest-client/src/test/java/org/zanata/rest/client/InvalidContentTypeFilterTest.java +++ b/zanata-rest-client/src/test/java/org/zanata/rest/client/InvalidContentTypeFilterTest.java @@ -49,7 +49,7 @@ public void testValidateContentTypes() { MatcherAssert.assertThat( isContentTypeCompatible( MediaType.APPLICATION_FORM_URLENCODED_TYPE), - equalTo(false)); + equalTo(true)); MatcherAssert.assertThat( isContentTypeCompatible(MediaType.MULTIPART_FORM_DATA_TYPE), equalTo(false)); @@ -60,6 +60,10 @@ public void testValidateContentTypes() { MatcherAssert.assertThat( isContentTypeCompatible(MediaType.APPLICATION_JSON_TYPE), equalTo(true)); + + MatcherAssert.assertThat( + isContentTypeCompatible(MediaType.APPLICATION_OCTET_STREAM_TYPE), + equalTo(true)); MatcherAssert.assertThat( isContentTypeCompatible(MediaType.WILDCARD_TYPE), equalTo(true));