开发者

Is there any way to check if a POST url exists?

Is there开发者_运维问答 any way to determine if a POST endpoint exists without actually sending a POST request?

For GET endpoints, it's not problem to check for 404s, but I'd like to check POST endpoints without triggering whatever action resides on the remote url.


Sending an OPTIONS request may work


It may not be implemented widely but the standard way to do this is via the OPTIONS verb.

WARNING: This should be idempotent but a non-compliant server may do very bad things

OPTIONS Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource.

More information here


This is not possible by definition.

The URL that you're posting to could be run by anything, and there is no requirement that the server behave consistently.

The best you could do is to send a GET and see what happens; however, this will result in both false positives and false negatives.


You could send a HEAD request, if the server you are calling support it - the response will typically be way smaller than a GET.


Does endpoint = script? It was a little confusing.

I would first point out, why would you be POSTing somewhere if it doesn't exist? It seems a little silly?

Anyway, if there is really some element of uncertainty with your POST URL, you can use cURL, then set the header option in the cURL response. I would suggest that if you do this that you save all validated POSTs if its likely that the POST url would be used again.

You can send your entire POST at the same time as doing the CURL then check to see if its errored out.

I think you probably answered this question yourself in your tags of your question with cURL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜