|
postget-dev | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
dev.postget.http.PostgetDevServlet
public class PostgetDevServlet
Relays a GET as a POST. A servlet for clients that can only send a GET. The caller writes the address and the body of a request into a link and fetches the link; the servlet sends that request as a POST, or with another method if one is asked for, and returns the other side's answer. Custom headers are passed on. Any public http or https address can be reached. No account and no key is needed, and there is no charge.
Example:
postget-dev: Relays a GET as a POST
Put the address and the body in a link and fetch it. This POSTs
{"name":"test"} to https://example.com/api and gives you whatever
example.com answered, status code and headers included:
https://www.postget.dev/api/post?url=https://example.com/api&body=%7B%22name%22%3A%22test%22%7D
With curl, which does the encoding for you:
curl -G https://www.postget.dev/api/post --data-urlencode 'url=https://example.com/api' --data-urlencode 'body={"name":"test"}'
Something other than a POST, or with headers of your own:
https://www.postget.dev/api/post?url=https://example.com/api/7&method=DELETE
https://www.postget.dev/api/post?url=https://example.com/api/7&method=PUT&body=name%3Dnew&headers=%7B%22Authorization%22%3A%22Bearer%20abc%22%7D
headers is a JSON object, here {"Authorization":"Bearer abc"}. A body
that is JSON goes out as application/json, a=1&b=2 as a form, anything
else as text; content_type=... says otherwise. Add response=json to
get the answer wrapped in an object with "status", "headers" and
"body". http and https only. Redirects are followed. No key, no
account.
| Constructor Summary | |
PostgetDevServlet() | |
| Method Summary | |
protected void |
doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Reads the request written into the link, sends it on and returns the answer. |
protected void |
doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Provided for completeness; callers are expected to arrive by GET. |
java.lang.String |
getServletInfo()Returns the name of this servlet. |
protected void |
sendOn(java.lang.String dest, byte[] data)Deprecated. |
protected void |
service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Receives every request and hands it to the method that answers it. |
| Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PostgetDevServlet()
| Method Detail |
protected void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
To invoke this method from a browser:
doGet in class javax.servlet.http.HttpServletreq - the request as it arrived, a GET with the real request written into it
resp - the response, which receives the other side's answer
javax.servlet.ServletException - if the request cannot be relayed
java.io.IOException - if the other side cannot be reached or stops answering
protected void doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
doPost in class javax.servlet.http.HttpServletreq - the request as it arrived, a GET with the real request written into it
resp - the response, which receives the other side's answer
javax.servlet.ServletException - if the request cannot be relayed
java.io.IOException - if the other side cannot be reached or stops answering
protected void service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
java.io.IOException
service in class javax.servlet.http.HttpServletreq - the request as it arrived, a GET with the real request written into it
resp - the response, which receives the other side's answer
javax.servlet.ServletException - if the request cannot be relayed
java.io.IOException - if the other side cannot be reached or stops answering
protected void sendOn(java.lang.String dest,
byte[] data)
throws java.io.IOException
dest - where to senddata - what to send
java.io.IOExceptionpublic java.lang.String getServletInfo()
postget-dev
|
postget-dev | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||