how to set authorization header with android's httpURLconnection
问题 I am attempting to connect to my server using basic authentication, but when I set the Authorization header, it causes getInputStream to throw a fileNotFound exception. Here is the relevant code: URL url = new URL(myurl); //set up the connection HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(10000);//this is in milliseconds conn.setConnectTimeout(15000);//this is in milliseconds String authHeader = getAuthHeader(userID,pass); conn.setRequestMethod("GET"