HttpClient { static byte[] getBoundary(final MediaType mediaType) throws IOException { if (!"byteranges".equals(mediaType.subtype())) { throw new IOException("Invalid multipart subtype " + mediaType.subtype() + ", expected 'byteranges'"); } final List<String> value = mediaType.parameters().get("boundary"); if (value.isEmpty()) { throw new IOException("Missing multipart boundary parameter"); } return value.get(0).getBytes(ISO_8859_1); } HttpClient(OkHttpClient okHttpClient); static HttpClient newHttpClient(); static HttpClient newHttpClient(OkHttpClient okHttpClient); void get(URI uri, Path output, Map<String, ? extends Credentials> credentials, HttpTransferListener listener); InputStream get(URI uri, Map<String, ? extends Credentials> credentials, HttpTransferListener listener); void partialGet(URI uri, List<ContentRange> ranges, Map<String, ? extends Credentials> credentials,
      RangeReceiver receiver, RangeTransferListener listener);  }
@Test(expected = IOException.class) public void testGetBoundaryNoAttributeValue() throws IOException { getBoundary(MediaType.create("multipart", "byteranges")); }
@Test(expected = IOException.class) public void testGetBoundaryInvalidSubtype() throws IOException { getBoundary(MediaType.create("multipart", "mixed")); }
@Test public void testGetBoundary() throws IOException { final String expected = "gc0p4Jq0M2Yt08jU534c0p"; assertArrayEquals(expected.getBytes(ISO_8859_1), getBoundary(MediaType.create("multipart", "byteranges") .withParameters(ImmutableMultimap.of("boundary", expected)))); }