public synchronized OutputStream getOutputStream() throws IOException { OutputStream os; String savedMethod = method; // see if the method supports output if (method.equals("PUT") || method.equals("POST") || method.equals("NOTIFY")) { // fake the method so the superclass method sets its instance variables method = "PUT"; } else { // use any method that doesn't support output, an exception will be // raised by the superclass method = "GET"; } os = super.getOutputStream(); method = savedMethod; return os; }
java.net.UnknownHostException: updaters at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at sun.net.NetworkClient.doConnect(NetworkClient.java:163) at sun.net.www.http.HttpClient.openServer(HttpClient.java:388) at sun.net.www.http.HttpClient.openServer(HttpClient.java:523) at sun.net.www.http.HttpClient.<init>(HttpClient.java:227) at sun.net.www.http.HttpClient.New(HttpClient.java:300) at sun.net.www.http.HttpClient.New(HttpClient.java:317) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836) at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2113) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1367) at Host.excutePost(Host.java:43) at Host.main(Host.java:14)
Exception in thread "main" java.io.FileNotFoundException: http://dl.dropbox.com/u/34206572/version.txt at sun.net.www.protocol.http.HttpURLConnection.getInputStream( HttpURLConnection.java:1610)
import java.io.IOException; import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import sun.net.www.protocol.http.Handler; import sun.net.www.protocol.http.HttpURLConnection; public class MyUrlConnectionHandler extends Handler { @Override protected URLConnection openConnection(URL url, Proxy proxy) throws IOException { if (url.toString().contains("ajax=1")) { return new AjaxHttpURLConnection(url, proxy, this); } // Return a default HttpURLConnection instance. return new HttpURLConnection(url, proxy); } }
sun.net.www.protocol.http.HttpURLConnection.doTunneling()
protected InputStream getResponseStream(URLConnection pURLConnection) throws IOException { sun.net.www.protocol.http.HttpURLConnection conn1 = null; if (pURLConnection instanceof sun.net.www.protocol.http.HttpURLConnection) { conn1 = (sun.net.www.protocol.http.HttpURLConnection) pURLConnection; } if (mResponseCode == HttpURLConnection.HTTP_BAD_METHOD || mResponseCode == HttpURLConnection.HTTP_BAD_REQUEST || mResponseCode == HttpURLConnection.HTTP_NOT_FOUND || mResponseCode == HttpURLConnection.HTTP_BAD_GATEWAY || mResponseCode == HttpURLConnection.HTTP_INTERNAL_ERROR) { if (null != conn1) { return conn1.getErrorStream(); } else { return pURLConnection.getInputStream(); } } else { return pURLConnection.getInputStream(); } }
try { InputStream in = new URL(myUrl).openConnection().getInputStream(); } catch (IllegalArgumentException iae) { in = sun.net.www.protocol.http.HttpURLConnection.openConnectionCheckRedirects(new URL(myUrl).openConnection()); }
Exception in thread "main" java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:695) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:640) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195) at test.Main.main(Main.java:25)
public synchronized OutputStream getOutputStream() throws IOException { OutputStream os; String savedMethod = method; // see if the method supports output if (method.equals("PUT") || method.equals("POST") || method.equals("NOTIFY")) { // fake the method so the superclass method sets its instance variables method = "PUT"; } else { // use any method that doesn't support output, an exception will be // raised by the superclass method = "GET"; } os = super.getOutputStream(); method = savedMethod; return os; }
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect (AbstractDelegateHttpsURLConnection.java:166) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLCo nnection.java:1014) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Htt