@@ -68,6 +68,8 @@ public void testParseAsString_none() throws Exception {
68
68
private static final String VALID_CONTENT_TYPE = "text/plain" ;
69
69
private static final String VALID_CONTENT_TYPE_WITH_PARAMS =
70
70
"application/vnd.com.google.datastore.entity+json; charset=utf-8; version=v1; q=0.9" ;
71
+ private static final String VALID_CONTENT_TYPE_WITHOUT_CHARSET =
72
+ "text/csv; version=v1; q=0.9" ;
71
73
private static final String INVALID_CONTENT_TYPE = "!!!invalid!!!" ;
72
74
private static final String JSON_CONTENT_TYPE = "application/json" ;
73
75
@@ -194,6 +196,32 @@ public LowLevelHttpResponse execute() throws IOException {
194
196
assertEquals ("ISO-8859-1" , response .getContentCharset ().name ());
195
197
}
196
198
199
+ public void testParseAsString_validContentTypeWithoutCharSetWithParams () throws Exception {
200
+ HttpTransport transport =
201
+ new MockHttpTransport () {
202
+ @ Override
203
+ public LowLevelHttpRequest buildRequest (String method , String url ) throws IOException {
204
+ return new MockLowLevelHttpRequest () {
205
+ @ Override
206
+ public LowLevelHttpResponse execute () throws IOException {
207
+ MockLowLevelHttpResponse result = new MockLowLevelHttpResponse ();
208
+ result .setContent (SAMPLE2 );
209
+ result .setContentType (VALID_CONTENT_TYPE_WITHOUT_CHARSET );
210
+ return result ;
211
+ }
212
+ };
213
+ }
214
+ };
215
+ HttpRequest request =
216
+ transport .createRequestFactory ().buildGetRequest (HttpTesting .SIMPLE_GENERIC_URL );
217
+
218
+ HttpResponse response = request .execute ();
219
+ assertEquals (SAMPLE2 , response .parseAsString ());
220
+ assertEquals (VALID_CONTENT_TYPE_WITHOUT_CHARSET , response .getContentType ());
221
+ assertNotNull (response .getMediaType ());
222
+ assertEquals ("UTF-8" , response .getContentCharset ().name ());
223
+ }
224
+
197
225
public void testParseAsString_jsonContentType () throws IOException {
198
226
HttpTransport transport =
199
227
new MockHttpTransport () {
0 commit comments