String host = Misc.extractHost(uri); int port = uri.getPort(); String path = uri.getRawPath();
public static String extractHost(URI uri) { // Extract the host part from the URI. String host = uri.getHost(); if (host != null) { return host; } // According to Issue#74, URI.getHost() method returns null in // the following environment when the host part of the URI is // a host name. // // - Samsung Galaxy S3 + Android API 18 // - Samsung Galaxy S4 + Android API 21 // // The following is a workaround for the issue. // Extract the host part from the authority part of the URI. host = extractHostFromAuthorityPart(uri.getRawAuthority()); if (host != null) { return host; } // Extract the host part from the entire URI. return extractHostFromEntireUri(uri.toString()); }
private void sendRequest() throws IOException { // Build a CONNECT request. String request = buildRequest(); // Convert the request to a byte array. byte[] requestBytes = Misc.getBytesUTF8(request); // Get the stream to send data to the proxy server. OutputStream output = mSocket.getOutputStream(); // Send the request to the proxy server. output.write(requestBytes); output.flush(); }
private static void initialize() throws Exception { // Constructor which represents javax.net.ssl.SNIHostName(String). // The class is available since Java 1.8 / Android API Level 24 (Android 7.0) sSNIHostNameConstructor = Misc.getConstructor( "javax.net.ssl.SNIHostName", new Class<?>[] { String.class }); // Method which represents javax.net.ssl.SSLParameters.setServerNames(List<SNIServerName>). // The method is available since Java 1.8 / Android API Level 24 (Android 7.0) sSetServerNamesMethod = Misc.getMethod( "javax.net.ssl.SSLParameters", "setServerNames", new Class<?>[] { List.class }); }
public Huffman(int[] codeLensFromSym) { // Remember the minimum and maximum code lengths. mMinCodeLen = Math.max(Misc.min(codeLensFromSym), 1); mMaxCodeLen = Misc.max(codeLensFromSym); // Count the number of entries for each code length. int[] countsFromCodeLen = createCountsFromCodeLen(codeLensFromSym, mMaxCodeLen); // Create an array holding the maximum code values for each code length. Object[] out = new Object[2]; mMaxCodeValsFromCodeLen = createMaxCodeValsFromCodeLen(countsFromCodeLen, mMaxCodeLen, out); // Create a table to convert code values int symbols. int[] codeValsFromCodeLen = (int[])out[0]; int maxCodeVal = ((Integer)out[1]).intValue(); mSymsFromCodeVal = createSymsFromCodeVal(codeLensFromSym, codeValsFromCodeLen, maxCodeVal); }
public static String join(Collection<?> values, String delimiter) { StringBuilder builder = new StringBuilder(); join(builder, values, delimiter); return builder.toString(); }
private static void setServerNames(SSLParameters parameters, String[] hostnames) { // Call parameters.setServerNames(List<SNIServerName>) method. Misc.invoke(sSetServerNamesMethod, parameters, createSNIHostNames(hostnames)); }
private static void initialize() throws Exception { // Constructor which represents javax.net.ssl.SNIHostName(String). // The class is available since Java 1.8 / Android API Level 24 (Android 7.0) sSNIHostNameConstructor = Misc.getConstructor( "javax.net.ssl.SNIHostName", new Class<?>[] { String.class }); // Method which represents javax.net.ssl.SSLParameters.setServerNames(List<SNIServerName>). // The method is available since Java 1.8 / Android API Level 24 (Android 7.0) sSetServerNamesMethod = Misc.getMethod( "javax.net.ssl.SSLParameters", "setServerNames", new Class<?>[] { List.class }); }
public Huffman(int[] codeLensFromSym) { // Remember the minimum and maximum code lengths. mMinCodeLen = Math.max(Misc.min(codeLensFromSym), 1); mMaxCodeLen = Misc.max(codeLensFromSym); // Count the number of entries for each code length. int[] countsFromCodeLen = createCountsFromCodeLen(codeLensFromSym, mMaxCodeLen); // Create an array holding the maximum code values for each code length. Object[] out = new Object[2]; mMaxCodeValsFromCodeLen = createMaxCodeValsFromCodeLen(countsFromCodeLen, mMaxCodeLen, out); // Create a table to convert code values int symbols. int[] codeValsFromCodeLen = (int[])out[0]; int maxCodeVal = ((Integer)out[1]).intValue(); mSymsFromCodeVal = createSymsFromCodeVal(codeLensFromSym, codeValsFromCodeLen, maxCodeVal); }
private static void setServerNames(SSLParameters parameters, String[] hostnames) { // Call parameters.setServerNames(List<SNIServerName>) method. Misc.invoke(sSetServerNamesMethod, parameters, createSNIHostNames(hostnames)); }
public void write(String string) throws IOException { // Convert the string into a byte array. byte[] bytes = Misc.getBytesUTF8(string); write(bytes); }
public static String extractHost(URI uri) { // Extract the host part from the URI. String host = uri.getHost(); if (host != null) { return host; } // According to Issue#74, URI.getHost() method returns null in // the following environment when the host part of the URI is // a host name. // // - Samsung Galaxy S3 + Android API 18 // - Samsung Galaxy S4 + Android API 21 // // The following is a workaround for the issue. // Extract the host part from the authority part of the URI. host = extractHostFromAuthorityPart(uri.getRawAuthority()); if (host != null) { return host; } // Extract the host part from the entire URI. return extractHostFromEntireUri(uri.toString()); }
public static String join(Collection<?> values, String delimiter) { StringBuilder builder = new StringBuilder(); join(builder, values, delimiter); return builder.toString(); }
String host = Misc.extractHost(uri); int port = uri.getPort(); String path = uri.getRawPath();
public static String encode(String data) { if (data == null) { return null; } return encode(Misc.getBytesUTF8(data)); }
@Override public byte[] generate() { return Misc.getBytesUTF8(String.valueOf(increment())); }
/** * Set the payload. The given string is converted to a byte array * in UTF-8 encoding. * * <p> * Note that the payload length of a <a href="http://tools.ietf.org/html/rfc6455#section-5.5" * >control frame</a> must be 125 bytes or less. * </p> * * @param payload * The unmasked payload. {@code null} is accepted. * An empty string is treated in the same way as * {@code null}. * * @return * {@code this} object. */ public WebSocketFrame setPayload(String payload) { if (payload == null || payload.length() == 0) { return setPayload((byte[])null); } return setPayload(Misc.getBytesUTF8(payload)); }
byte[] encodedReason = Misc.getBytesUTF8(reason);