java.net.URLConnection#getRequestProperty ( )源码实例Demo

下面列出了java.net.URLConnection#getRequestProperty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码2 项目: TencentKona-8   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码3 项目: jdk8u60   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码6 项目: openjdk-jdk9   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码7 项目: jdk8u-jdk   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码8 项目: hottub   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码9 项目: openjdk-8-source   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码10 项目: openjdk-8   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码11 项目: jdk8u_jdk   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码12 项目: jdk8u-jdk   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码13 项目: jdk8u-dev-jdk   文件: RequestPropertyValues.java
public static void part2() throws Exception {
    URL url = null;
    String[] goodKeys = {"", "$", "key", "Key", " ", "    "};
    String[] goodValues = {"", "$", "value", "Value", " ", "    "};

    URLConnection conn = getConnection(url);

    for (int i = 0; i < goodKeys.length; ++i) {
        for (int j = 0; j < goodValues.length; ++j) {
            // If a property with the key already exists, overwrite its value with the new value
            conn.setRequestProperty(goodKeys[i], goodValues[j]);
            String value = conn.getRequestProperty(goodKeys[i]);

            if (!((goodValues[j] == null && value == null) || (value != null && value.equals(goodValues[j]))))
                throw new RuntimeException("Method setRequestProperty(String,String) works incorrectly");
        }
    }
}
 
源代码14 项目: cxf   文件: Headers.java
/**
 * This procedure sets the URLConnection request properties
 * from the PROTOCOL_HEADERS in the message.
 */
private void transferProtocolHeadersToURLConnection(URLConnection connection) {
    boolean addHeaders = MessageUtils.getContextualBoolean(message, ADD_HEADERS_PROPERTY, false);
    for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
        String header = entry.getKey();
        if (HttpHeaderHelper.CONTENT_TYPE.equalsIgnoreCase(header)) {
            continue;
        }

        List<String> headerList = entry.getValue();
        if (addHeaders || HttpHeaderHelper.COOKIE.equalsIgnoreCase(header)) {
            headerList.forEach(s -> connection.addRequestProperty(header, s));
        } else {
            connection.setRequestProperty(header, String.join(",", headerList));
        }
    }
    // make sure we don't add more than one User-Agent header
    if (connection.getRequestProperty("User-Agent") == null) {
        connection.addRequestProperty("User-Agent", USER_AGENT);
    }
}