Here you can find the source of addHeaders(URLConnection conn)
Parameter | Description |
---|---|
conn | the connection to modify |
public static void addHeaders(URLConnection conn) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.net.URLConnection; public class Main { public static String userAgent; /**//from w ww .java 2 s.co m * adds headers to the url to make it look less like a bot * @param conn the connection to modify */ public static void addHeaders(URLConnection conn) throws IOException { conn.addRequestProperty("User-Agent", userAgent); conn.addRequestProperty("Accept-Language", "en-US,en;q=0.5"); conn.addRequestProperty("Accept-Encoding", "gzip,deflate"); conn.addRequestProperty("DNT", "1"); } }