How do you force a web browser to use POST when getting a url?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
I know this question is old but someone may find this useful. You can use a command line tool like cURL (http://curl.haxx.se/) to post to a URL.
Example:
You can use a tool to test. I'm always asking the same question as you. There is quite a few tools available online. Here is the tool that I use: http://www.hurl.it/
Use an HTML form that specifies post as the method:
If you had to make it happen as a link (not recommended), you could have an onclick handler dynamically build a form and submit it.
If you need to enforce this on the server side, you should check the HTTP method and if it's not equal to POST, send an HTTP 405 response code (method not allowed) back to the browser and exit. Exactly how you implement that will depend on your programming language/framework, etc.
The above submitAsPost() function is a good and elegant solution but it has a problem - if the URL is too long some browsers (including Firefox and IE) will return an error. Since many of us use POST in order to bypass this very limitation, I suggest this solution:
Tested with Firefox, Chrome and IE.
This is a little late in the game but I ran across this and found that HTML 5 made some changes. You can use the input tag to add formmethod (thus selecting post). This worked for me.
see : http://www.w3schools.com/tags/att_input_formmethod.asp
I have a feeling from your question you were just hoping to send a post request in a browser's address bar.
Just type the following into the address bar swapping the value for 'action' to the url that you like.
It's invalid html, but the browser's (at least all the ones i've tested it in so far) know what you mean, and I wanted to keep it as short as I could.
If you want to post values, append as many inputs as you like, swapping name and value in each input for whatever you like.
It's important to note that sensitive information you post will be visible in:
It's a really bad way to send a post request, and all the other answers are far better, but it's still cool that you can do it.