httpurlconnection

HttpURLConnection.getInputStream very slow

坚强是说给别人听的谎言 提交于 2019-12-08 22:08:17
问题 HttpURLConnection.getInputStream takes very much time when compared to iPhone App which uses the same server side services. The following code is used for the service : date= new java.util.Date(); Log.d("time","Time Stamp before posting "+new Timestamp(date.getTime())); URL ur= new URL(url); HttpURLConnection conn = (HttpURLConnection) ur.openConnection(); conn.setRequestProperty("Connection", "close"); conn.setReadTimeout(10000); conn.setConnectTimeout(15000); conn.setRequestMethod("POST");

java.io.IOException: unexpected end of stream on Connection? [duplicate]

自作多情 提交于 2019-12-08 21:44:22
问题 This question already has answers here : java.io.IOException: unexpected end of stream on Connection in android (7 answers) Closed 3 months ago . Calling one of our in-house web services seems to be giving the following error: java.io.IOException: unexpected end of stream on Connection{webservicessandbox.xxx.com:443, proxy=DIRECT@ hostAddress=174.143.185.13 cipherSuite=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA protocol=http/1.1} (recycle count=0) From what I've seen elsewhere, this is being pointed

Java HttpURLConnection: Content Length computation

你离开我真会死。 提交于 2019-12-08 17:38:35
问题 I'm currently developing a library for the bitbucket issues RESTful API. I made good progress and now I'm going to tackle the section Updating an Issue which demands an HTTP PUT Request. Now I'm stuck because of the HTTP Error Code 411 Length Required . After a bit of googling, I found the following code example: // CORRECT: get a UTF-8 encoded byte array from the response // String and set the content-length to the length of the // resulting byte array. String response = [insert XML with UTF

HttpURLConnection getInputStream() has one second delay

心不动则不痛 提交于 2019-12-08 14:29:28
I am using HttpURLConnection for making POST requests. I observe always the same behaviour during tests: first request runs very fast (miliseconds) all following requests take one second + some miliseconds So something is causing 1 second delay. What can it be? The delay is happening exactly in HttpURLConnection#getInputStream(). I replaced the implementation with HttpClient - then everything is OK, no second delays (so it is not the server fault). But I really don't want to use any external dependency, so I would like to fix the HttpURLConnection thing... Any ideas? Below current

Single URLConnection to fetch only the first line in java using BufferedReader

非 Y 不嫁゛ 提交于 2019-12-08 12:46:03
问题 I am trying to write a Java program that should automatically download text from a website if and only if it gets updated. The problem I am running into is using only one HTTPURLConnection to do that because if i don't there will be billions of HTTPURLConnections to the web server since I am using a while(true) loop. Here is my work-in-progress, the getMsg() method receives a url and opens an HTTPURLConnection. Currently I am starting a new connection every time I have to read a line, which

OOZIE : Connection exception has occurred [ java.net.ConnectException Connection refused (Connection refused) ]

邮差的信 提交于 2019-12-08 11:19:27
问题 I'm trying to execute Oozie job with the help of URL: https://www.safaribooksonline.com/library/view/apache-oozie/9781449369910/ch05.html While executing oozie job -run -config target/example/job.properties Getting error as : Connection exception has occurred [ java.net.ConnectException Connection refused (Connection refused) ]. Trying after 1 sec. Retry count = 1 Connection exception has occurred [ java.net.ConnectException Connection refused (Connection refused) ]. Trying after 2 sec. Retry

POST File with HttpURLConnection to PHP

纵饮孤独 提交于 2019-12-08 09:42:10
问题 I already referred this link Sending files using POST with HttpURLConnection Using the following code, I'm trying to POST a file to local PHP server. It always return file size 0 in my PHP file public class FileUpload2 { String CRLF = "\r\n"; /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { new FileUpload2().put("http://localhost/test/test.php"); } public void put(String targetURL) throws Exception { String BOUNDRY = "=========================

How to get file properties without downloading

纵饮孤独 提交于 2019-12-08 09:37:13
问题 How to get file properties (e.g. date) without downloading file if I have URL of the file. I have to implement updates checker. For this purpose I'm going to compare dates of two files. One is local, the second is the same file but with latest date on server. I know URL to the second file. Please, give me a peace of advice - how to check date of the second file without downloading it? I have thought about comparing via hash, but I need to check whether file on server is latest version or not?

How to set “jsse.enableSNIExtension” to false only for a single HTTPURLConnection?

╄→尐↘猪︶ㄣ 提交于 2019-12-08 07:06:36
问题 I currently have an application that would make HTTP post request to a lot of URLs. Some of the connections are failing with the following exception. Exception in thread "main" javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name at sun.security.ssl.ClientHandshaker.handshakeAlert(ClientHandshaker.java:1410) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2004) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1113) at sun.security.ssl

HttpURLConnection getResponseCode not returning

老子叫甜甜 提交于 2019-12-08 06:33:53
问题 I'm trying to POST a file to our server using HttpURLConnection on Android, but the getResponseCode call just hangs and never returns. The issue stems from the file being too big for the server, so the server sends back an HTTP error code of 413 (which I can see in the server logs), but on our device, it seems like this is never received. I have the following code in our app: public FileUploadUtility(URL requestURL, File uploadFile) throws IOException { file = uploadFile; String fileName =