? Now I know the difference between the parameters in the UR...">

Is there any difference between the parameters in the url and the <form method = "get">?

Now I know the difference between the parameters in the URL and the POST parameter: some browsers may err if the URL is too long, so it's nice to type hundreds of parameters in the URL, even if your application can respond to a GET request.

For discussion, suppose the following web application: the user can enter a series (possibly hundreds) of X, Y coordinates. The server displays them on a diagram that returns as an image.

This is certainly an example of idempotent operation , so according to the HTTP spec , it is recommended that you implement it as a GET operation. However, you cannot create a URL with all parameters as it will be too long. Can <form method = "get"> handle many parameters?

I also heard that <form method = "get"> is completely equivalent to placing the parameters in the url? Now is this true for some browsers or the entire HTTP protocol? Is there a maximum request length?

+6
url limits
source share
8 answers

The HTTP specification does not set limits, but browsers and servers do. See here for more details.

A long URL will be created in the browser if the method is set to GET for the form, so the above restrictions apply.

+7
source share

The HTTP specification does not require special specification of GET request parameters in the URI. It would be legal to send the body of a message in a GET request, for example using POST.

However, browsers implement GET forms this way for a very good reason: caching. GET requests are expected to be processed on the server without side effects. Thus, responses to GET requests can be cached. This performance improvement opportunity is instantly lost if you start using message bodies in GET requests.

If you plan to develop charting APIs, you can take a look at Google . They already offer a very good audience. Even if it is only to learn how to collect as much information as possible in the parameters of the URI, it is worth a look.

alt textalt textalt textalt text

+3
source share

In fact, your browser does build a very long URL from the inputs of the form. Therefore, there will be no difference between the URL and the Method = "GET" form. Any of these will load the same URL.

+2
source share

form method = get WILL put the entire form in the URL.

It is true that browsers have the maximum length for a URL. It varies from browsers to browsers and, of course, from the version of browsers to the version of browsers.

If you can, I would recommend you use POST for your form.

NTN

+1
source share

GET and url? name = value & ... is the same that the browser simply converts the GET form to a URL before sending the request.

The maximum length of the URL is determined at the browser and server level, so for this browser / server it is the smaller of the two.

This post has a good list of current maximum lengths for URLS

+1
source share

No, the server does not see the difference between placing parameters in the URL and using FORM using the GET method. Thus, if the given URL with parameters is too long, using FORM with the GET method will not help.

POST or GET should be chosen mainly for their semantics. GET is for "safe" activities. That is, users should not be held responsible for the operation performed by the GET request. The POST method is used for operations for which the user should be responsible.

This is very unpleasant, for example, when the search function uses POST. The user does not expect a simple query to change any important state of the system - they expect the search to be "safe".

On the other hand, there are many vulnerabilities because unsafe operations are accessible through GET requests as well as POST requests. This contributes to vulnerabilities such as XSRF, where an attacker just needs to get the malicious src URL into an IMG tag on a legit site.

In your case, using Ajax might be the appropriate solution. You can make a GET request for each selected point by storing it in a session on the server. When the user completes the entry of points, the final GET request receives the finished product.

+1
source share

I also heard that <form method = "get"> is completely equivalent to placing the parameters in the url?

That's true, here is the relevant section of the RFC

Is there a maximum request length?

spec says: "The HTTP protocol does not set an a priori limit on the length of the URI."

However, Internet explorer 6 has a 2.083 character limit. Other browsers allow more characters, but if you go along this route, you will mainly need to create for ie6

0
source share

This is not an answer to your question about receiving and publishing, but in such a situation, as you describe, it is quite often easier to store more complex data on the server and associate it with the session ID or user account than putting it in the URL each time. Then you can use only the identifier for this session in the cookie or as the url parameter to retrieve the image.

It will also help you cache the requested images so that you donโ€™t have to do the work of regenerating them every time the user wants to look at a specific schedule again.

0
source share

All Articles