Hi I need to evaluate if a server supports gzip compression.
Therefore I want to set gzip as Accept-Encoding in my request and evaluate if the response of the server containts "Content-Encoding: gzip".
However I am not quite clear on how to do this with HTTPURLConnection. Especially when to query my Connection object about the respons...
We're implementing a REST client on JRE 1.4.
Seems two good options for a client REST framework are HttpClient and HttpUrlConnection.
Is there a reason to use HttpClient over the JRE's HttpUrlConnection?
...
I am attempting to download a jpg using HttpURLConnection and am encountering a very peculiar bug.
Here's the url:
http://www.vh1.com/sitewide/promoimages/shows/m/my%5Fantonio/video/supertrailer/seg%5F1/320x240.jpg
if you open it in a browser you will see the image.
However, when I use HttpURLConnection I don't get the image...
What I...
Hi everyone,
I can't understand why Java HttpURLConnection doesn't follow redirect. I use the following code to get the page http://bit.ly/4hW294:
import java.net.URL;
import java.net.HttpURLConnection;
import java.io.InputStream;
public class Tester {
public static void main(String argv[]) throws Exception{
InputStream i...
We are using HttpURLConnection API to invoke a REST API to the same provider often (kind of an aggregation usecase). We want to keep a pool of 5 connections always open to the provider host (always the same IP).
What is the proper solution? Here is what we tried:
System.setProperty("http.maxConnections", 5); // set globally only once...
Hi guys.
Do you know how to set Content-Type on HttpURLConnection?
Following code is on Blackberry and I want the Android equivalent:
connection.setRequestProperty("content-type", "text/plain; charset=utf-8");
connection.setRequestProperty("Host", "192.168.1.36");
connection.setRequestProperty("Expect", "100-continue");
Is it right...
Hello experts!
I'm building an android app which should perform a GET on my site to get two cookies and then perform a post to the same site with these cookies.
As mentioned I start of with the GET and I'm using org.apache.http.client.HttpClient to perform this operation.
String requiredCookies = "";
HttpContext localContext = null;...
The method disconnect from HttpURLConnection seems not to work properly.
If I execute the following code:
url = new URL ("http:// ...");
connection = (HttpURLConnection) url.openConnection ();
connection.setRequestMethod ("POST");
connection.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
connection.setUseCache...
How do you do do an HTTP PUT? The class I'm using seems to think it is doing a PUT but the endpoint is treating it as if I did a GET. Am I doing anything wrong?
URL url = new URL("https://...");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("PUT");
OutputStreamWriter wr...
Hello,
I'm trying to write a program to do automated testing on my webapp. To accomplish this, I open up a connection using HttpURLConnection.
One of the pages that I'm trying to test performs a 302 redirect. My test code looks like this :
URL currentUrl = new URL(urlToSend);
HttpURLConnection connection = (HttpURLConnection) curr...
I'm hoping someone could help me out with intermittent connections I'm
getting using code with HttpsURLConnection. The code I'm using is
below:
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setReadTimeout(10 * 1000);
if conn.getResponseCode() != 200) {
Log.v(TAG, "error code:" + c...
Hi all,
I wanted to get some advice, I have started on a new project to create a java download accelerator that will use multiple connections. I wanted to know how best to go about this.
So far I have figured out that i can use HttpUrlConnection and use the range property, but wanted to know an efficient way of doing this. Once i hav...
[Java 1.5; Eclipse Galileo]
HttpsURLConnection seems to stall when the getInputStream() method is called. I've tried using different websites to no avail (currently https://www.google.com). I should point out I'm using httpS.
The code below has been modified based on what I've learned from other StackOverflow answers. However, no solut...
Hi,
Right so, I started my project on creating a Java download manager which is going nicely. The only problem I am seeing at the moment is when i request the content length of the URL. When i use the method provided by HttpUrlConnection's getContentLength, it returns an Int.
This is great if i was only to ever download files that we...
I am trying to connect a web server I have running in my android App however for some reason it's failing.
I can connect to the webpage normally and using my phone's browser, I can also use the below code to connect to google but for some reason my code will not connect to my web server. If I host the server on port 80 I get error code ...
Hi all
I'm making call to Alfresco Webscripts which return JSON. I do this using GET requests which all work perfectly. If I do a file POST however, the Alfresco server receives the file correctly and sends back a JSON response, but this time the response causes the browser to prompt for a download instead of the letting Javascript proc...
Hi!
How can I do several request in one HttpURLConnection with Java?
URL url = new URL("http://my.com");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
HttpURLConnection.setFollowRedirects( true );
connection.setDoOutput( true );
connection.setRequestMethod("GET");
PrintStream ps = new PrintStream( conne...
Hello,
I have this piece of code which I'm hoping will be able to tell me how much data I have downloaded (and soon put it in a progress bar), and then parse the results through my Sax Parser. If I comment out basically everything above the //xr.parse(new InputSource(request.getInputStream())); line and swap the xr.parse's over, it wor...
Hi everyone, I have a weird issue. I receive the following error that causes a force-close:
org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element found at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:508)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467)
...
HTTPUrlConnection.setContentHandlerFactory()method throws Exception saying factory is already defined. I understand that. Is it possible to unset the factory and change the contenthandler factory?
...