/** * Sets URI fragment. The value is expected to be unescaped and may contain non ASCII * characters. * * @return this. */ public URIBuilder setFragment(final String fragment) { this.fragment = !TextUtils.isBlank(fragment) ? fragment : null; this.encodedFragment = null; return this; }
public static void notEmpty(final CharSequence s, final String name) { if (TextUtils.isEmpty(s)) { throw new IllegalStateException(name + " is empty"); } }
public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name) { if (argument == null) { throw illegalArgumentExceptionNotNull(name); } if (argument.length() == 0) { throw illegalArgumentExceptionNotEmpty(name); } if (TextUtils.containsBlanks(argument)) { throw new IllegalArgumentException(name + " must not contain blanks"); } return argument; }
@Override public void endStream(final List<? extends Header> trailers) throws IOException { digest = digester.digest(); final List<Header> allTrailers = new ArrayList<>(); if (trailers != null) { allTrailers.addAll(trailers); } allTrailers.add(new BasicHeader("digest-algo", digester.getAlgorithm())); allTrailers.add(new BasicHeader("digest", TextUtils.toHexString(digest))); channel.endStream(allTrailers); }
public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name) { if (argument == null) { throw illegalArgumentExceptionNotNull(name); } if (argument.length() == 0) { throw illegalArgumentExceptionNotEmpty(name); } if (TextUtils.containsBlanks(argument)) { throw new IllegalArgumentException(name + " must not contain blanks"); } return argument; }
@Override public void endStream(final List<? extends Header> trailers) throws IOException { digest = digester.digest(); final List<Header> allTrailers = new ArrayList<>(); if (trailers != null) { allTrailers.addAll(trailers); } allTrailers.add(new BasicHeader("digest-algo", digester.getAlgorithm())); allTrailers.add(new BasicHeader("digest", TextUtils.toHexString(digest))); channel.endStream(allTrailers); }
/** * Sets URI fragment. The value is expected to be unescaped and may contain non ASCII * characters. * * @return this. */ public URIBuilder setFragment(final String fragment) { this.fragment = !TextUtils.isBlank(fragment) ? fragment : null; this.encodedFragment = null; return this; }
public static void notEmpty(final CharSequence s, final String name) { if (TextUtils.isEmpty(s)) { throw new IllegalStateException(name + " is empty"); } }
public static Host create(final String s) throws URISyntaxException { Args.notEmpty(s, "HTTP Host"); final int portIdx = s.lastIndexOf(":"); int port; if (portIdx > 0) { try { port = Integer.parseInt(s.substring(portIdx + 1)); } catch (final NumberFormatException ex) { throw new URISyntaxException(s, "invalid port"); } final String hostname = s.substring(0, portIdx); if (TextUtils.containsBlanks(hostname)) { throw new URISyntaxException(s, "hostname contains blanks"); } return new Host(hostname, port); } throw new URISyntaxException(s, "port not found"); }
@Test public void testToHexString() { Assert.assertEquals("000c2001", TextUtils.toHexString(new byte[] { 0, 12, 32, 1 })); Assert.assertEquals(null, TextUtils.toHexString(null)); }
/** * Sets URI host. * * @return this. */ public URIBuilder setHost(final String host) { this.host = !TextUtils.isBlank(host) ? host : null; this.encodedSchemeSpecificPart = null; this.encodedAuthority = null; return this; }
public static <T extends CharSequence> T notEmpty(final T argument, final String name) { if (argument == null) { throw illegalArgumentExceptionNotNull(name); } if (TextUtils.isEmpty(argument)) { throw illegalArgumentExceptionNotEmpty(name); } return argument; }
if (atIdx > 0) { userInfo = hostname.substring(0, atIdx); if (TextUtils.containsBlanks(userInfo)) { throw new URISyntaxException(s, "user info contains blanks"); if (TextUtils.containsBlanks(hostname)) { throw new URISyntaxException(s, "hostname contains blanks");
@Test public void testConsumeData() throws Exception { final DigestingEntityConsumer<String> consumer = new DigestingEntityConsumer<>("MD5", new StringAsyncEntityConsumer()); consumer.consume(ByteBuffer.wrap(new byte[]{'1', '2', '3'})); consumer.consume(ByteBuffer.wrap(new byte[]{'4', '5'})); consumer.consume(ByteBuffer.wrap(new byte[]{})); consumer.streamEnd(null); Assert.assertEquals("12345", consumer.getContent()); Assert.assertEquals("0827c0cb0e0ea08a706c4c340a1680910f84e7b", TextUtils.toHexString(consumer.getDigest())); }
/** * Sets URI host. * * @return this. */ public URIBuilder setHost(final String host) { this.host = !TextUtils.isBlank(host) ? host : null; this.encodedSchemeSpecificPart = null; this.encodedAuthority = null; return this; }
public static <T extends CharSequence> T notEmpty(final T argument, final String name) { if (argument == null) { throw illegalArgumentExceptionNotNull(name); } if (TextUtils.isEmpty(argument)) { throw illegalArgumentExceptionNotEmpty(name); } return argument; }
public static Host create(final String s) throws URISyntaxException { Args.notEmpty(s, "HTTP Host"); final int portIdx = s.lastIndexOf(":"); int port; if (portIdx > 0) { try { port = Integer.parseInt(s.substring(portIdx + 1)); } catch (final NumberFormatException ex) { throw new URISyntaxException(s, "invalid port"); } final String hostname = s.substring(0, portIdx); if (TextUtils.containsBlanks(hostname)) { throw new URISyntaxException(s, "hostname contains blanks"); } return new Host(hostname, port); } throw new URISyntaxException(s, "port not found"); }
/** * Sets URI path. The value is expected to be unescaped and may contain non ASCII characters. * * @return this. */ public URIBuilder setPath(final String path) { this.path = !TextUtils.isBlank(path) ? path : null; this.encodedSchemeSpecificPart = null; this.encodedPath = null; return this; }
if (atIdx > 0) { userInfo = hostname.substring(0, atIdx); if (TextUtils.containsBlanks(userInfo)) { throw new URISyntaxException(s, "user info contains blanks"); if (TextUtils.containsBlanks(hostname)) { throw new URISyntaxException(s, "hostname contains blanks");