Search action should be an HTTP GET or a POST?
-
What do you think? Ok, basically doesn't matter, it works anyway but I like to have my HTTP verbs used the right way. Since ever I've been using GET to handle all the data pulling actions. So everytime I need to pull data from the server I use a GET, everytime I push data to the server I use a POST. Yesterday I had this discussion with a guy that argued that search operations (like an AJAX request that implements a grid filtering mechanism) must be a POST because it doesn't return a resource... (I really couldn't understand this answer... I tried to but it was impossible to make him explain to me what it meant by that in other words) Search operations, for me, naturally fit in the data pulling logic. Although it may be filtered data, and we may need to pass a bunch of filter options to the server, the operation itself is to retrieve data from the server. What do you think?
-
What do you think? Ok, basically doesn't matter, it works anyway but I like to have my HTTP verbs used the right way. Since ever I've been using GET to handle all the data pulling actions. So everytime I need to pull data from the server I use a GET, everytime I push data to the server I use a POST. Yesterday I had this discussion with a guy that argued that search operations (like an AJAX request that implements a grid filtering mechanism) must be a POST because it doesn't return a resource... (I really couldn't understand this answer... I tried to but it was impossible to make him explain to me what it meant by that in other words) Search operations, for me, naturally fit in the data pulling logic. Although it may be filtered data, and we may need to pass a bunch of filter options to the server, the operation itself is to retrieve data from the server. What do you think?
AlexCode wrote:
What do you think?
I think it depends on the circumstance and environment. I love to be able to bookmark a parameterized url, always more efficient than having to navigate to the page from the homepage. OTOH, I can imagine some people wanting to keep their search-terms private. Check out the history of your browser, and you'll see what I mean.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
AlexCode wrote:
What do you think?
I think it depends on the circumstance and environment. I love to be able to bookmark a parameterized url, always more efficient than having to navigate to the page from the homepage. OTOH, I can imagine some people wanting to keep their search-terms private. Check out the history of your browser, and you'll see what I mean.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
On your answer you actually give me one more reason why a search should be a GET (for bookmarking). Although this is not the case, is for internal ajax requests handling, but the same concept still applies. The only circonstance I can imagine using a POST instead of a GET on this is it the data to be passed to the server is such that there's a chance of overloading the URL max size standards. Otherwise, its a GET!!! :) Thanks!
-
On your answer you actually give me one more reason why a search should be a GET (for bookmarking). Although this is not the case, is for internal ajax requests handling, but the same concept still applies. The only circonstance I can imagine using a POST instead of a GET on this is it the data to be passed to the server is such that there's a chance of overloading the URL max size standards. Otherwise, its a GET!!! :) Thanks!
-
What do you think? Ok, basically doesn't matter, it works anyway but I like to have my HTTP verbs used the right way. Since ever I've been using GET to handle all the data pulling actions. So everytime I need to pull data from the server I use a GET, everytime I push data to the server I use a POST. Yesterday I had this discussion with a guy that argued that search operations (like an AJAX request that implements a grid filtering mechanism) must be a POST because it doesn't return a resource... (I really couldn't understand this answer... I tried to but it was impossible to make him explain to me what it meant by that in other words) Search operations, for me, naturally fit in the data pulling logic. Although it may be filtered data, and we may need to pass a bunch of filter options to the server, the operation itself is to retrieve data from the server. What do you think?
Yes, I think so.