httpurlconnection

HttpUrlConnection getOutputStream have plroblem

ぐ巨炮叔叔 提交于 2019-12-06 11:33:26
问题 i make a android application and used for HttpUrlConnection, POST method, HoloEverywhere Library but i have problem... why happen to problem that i don't know... im think that getOutputStream() error because if used to getOutputStream() method show message " application unfortunately, * has stopped." and stopped application. main.java import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import

How to reset URLConnection in java?

╄→гoц情女王★ 提交于 2019-12-06 11:17:38
is there any way to reset the connection,so that i can read from starting of the document? It is a slow process that reconnecting to read from sarting,i want to read a file 20 times per second through http,is there any other way to do this? URLConnection is an easy but somewhat "dumb" class. I can suggest you to do it the Java way: instantiate a new URLConnection. ;) Java is not really a language that encorages reusage of objects. You can try resetting the input stream, see the docs for more info, but I don't think it will do another GET. Who knows how the concrete implementation behind

Google App Engine ( Java ) : URL Fetch Response too large problems

青春壹個敷衍的年華 提交于 2019-12-06 10:44:39
问题 I'm trying to build some sort of webservice on google apps. Now the problem is, I need to get data from a website (HTML Scraping). The request looks like : URL url = new URL(p_url); con = (HttpURLConnection) url.openConnection(); InputStreamReader in = new InputStreamReader(con.getInputStream()); BufferedReader reader = new BufferedReader(in); String result = ""; String line = ""; while((line = reader.readLine()) != null) { System.out.println(line); } return result; Now App Engine gives me

HttpURLConnection App Engine Java Example for POST Request does not work

蓝咒 提交于 2019-12-06 06:58:36
I am trying to do a POST request using urlfetch under an app engine application. I have followed the instructions (and code) extracted from the simple example found at the App Engine documentation (here https://developers.google.com/appengine/docs/java/urlfetch/usingjavanet ), under the section "Using HttpURLConnection". import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; String message =

authenticate with ntlm (or kerberos) using java UrlConnection

佐手、 提交于 2019-12-06 03:34:20
问题 I need to consume a rest web service with java, passing the credentials of a domain user account. right now I'm doing it with classic asp set xmlHttp = server.createObject( "msxml2.serverxmlhttp" ) xmlHttp.open method, url, false, domain & "\" & user, password xmlHttp.send body out = xmlHttp.responseText set xmlHttp = nothing and with asp.net HttpWebRequest request = (HttpWebRequest) WebRequest.Create( url ); request.Credentials = new NetworkCredential(user, password, domain); request.Method

HttpURLConnection getting locked

北城余情 提交于 2019-12-06 01:44:48
问题 I have a thread running under tomcat which creates a HttpUrlConnection and reads it through BufferedInputStream. After fetching data for some urls, it stalls. I got the jstack of the process which says HttpUrlConnection is locked and BufferedInputStream is also locked. "http-8080-1" daemon prio=10 tid=0x08683400 nid=0x79c9 runnable [0x8f618000] java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java

HttpURLConnection conn.getRequestProperty return null

时光总嘲笑我的痴心妄想 提交于 2019-12-06 01:25:11
问题 I'm trying to push some data to an URL (MDS_CS) for a BES when i set some Request Headers in my code, and submit the request, the submited request's header is set to null . here is my code : HttpURLConnection conn =(HttpURLConnection)url.openConnection(); conn.setDoInput(true);//For receiving the confirmation conn.setDoOutput(true);//For sending the data conn.setRequestMethod("POST");//Post the data to the proxy conn.setRequestProperty("X-Rim-Push-ID", pushId); conn.setRequestProperty(

Switching from WiFi connection to 3g causes connection to hang?

一曲冷凌霜 提交于 2019-12-06 00:58:12
I have an application which connects to a web service. I can connect to the web service any number of times without any problem using WIFI or 3G provided that I stay loyal to my connection type during the life cycle of my application. That is if I don't switch from WIFI to 3G. If I switches from WIFI to 3G, I can't get a response anymore. My connection just keeps on waiting for response. I tried 4 scenarios below. I'm only having problem with the 3rd scenario. What could be the problem? 1st Scenario: Connection is always on WIFI (Ok) Application connects to a web service using WIFI. Response

使用Fiddler监听Java HttpURLConnection请求的小技巧

旧时模样 提交于 2019-12-06 00:55:19
参考资料 默认情况下Fiddler是不能监听Java HttpURLConnection上的HTTP请求的。原因容易理解,Fiddler能监听浏览器的HTTP请求是因为它启动一个代理服务器,浏览器通过这个代理服务器上网,但HttpURLConnection默认不使用该代理。 Fiddler 官方给出的解决方法是启动Java程序时设置代理,例如: java -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 Main2 stackoverflow 上有人提供了另一种方法: // set http proxy System.setProperty("http.proxyHost", "localhost"); System.setProperty("http.proxyPort", "8888"); // set https proxy System.setProperty("https.proxyHost", "localhost"); System.setProperty("https.proxyPort", "8888"); 使用以下代码访问 http://www.163.com/ 测试,以上两种方法都可行 public class Main2 { public static void main(String[] args

Send GET request with token using Java HttpUrlConnection

隐身守侯 提交于 2019-12-06 00:43:50
I have to work with RESTful web service which uses token-based authentication from Java application. I can successfully get token by this way: import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; public void getHttpCon() throws Exception{ String POST_PARAMS = "grant_type=password&username=someusrname&password=somepswd&scope=profile"; URL obj = new URL("http://someIP/oauth/token"); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty(