Skip to content
Advertisement

httpURLConnection: how long can a post argument be?

I’m currently using something like this:

 HttpURLConnection con = (HttpURLConnection) u.openConnection ();
     con.setDoInput(true);
     con.setRequestMethod("POST");
    
     con.setDoInput (true);
     con.setDoOutput (true);
     con.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
     
        out = new DataOutputStream(con.getOutputStream());
     String content = "username=" + URLEncoder.encode ("bob")
      + "&password=" + URLEncoder.encode ("smith");
     System.out.println("n" + "sending form to HTTP server ...");
     out.writeBytes (content);
     out.flush ();
     out.close ();
    
     con.connect();

With this I manage to pass some data to my server. What I’m wondering now is how much can be sent this way?

I want to be able to send some xml files (100-200 lines long) and would like to know if I can do this?

Jason

Advertisement

Answer

The post body (it’s not usually called an argument, since that usually implies it being passed with the URL) can be any length, restricted only by configuration.

Since POST is used to implement file uploads, most systems allow pretty large bodies. 100-200 lines should not be a problem at all, except for the most paranoid configurations out there.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement