HttpURLConnection: how long can the post argument be?

I am 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 transfer some data to my server. I'm wandering now, how much can I send this way?

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

Jason

+4
source share
3 answers

The body of the message (usually not called an argument, since it is usually assumed that it is passed with a URL) can be of any length, limited only by configuration.

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

+5
source

Any length, just keep in mind that your request may be a timeout. GET data is limited to 4096 bytes.

+2
source

The maximum message length is usually configured in the server configuration, and not on the client side.

+2
source

Source: https://habr.com/ru/post/1336763/


All Articles