in my Android app I need to run an HTTP web server. Initial bringup seems ok – I can receive requests and process the URI string when I’m using a Browser to navigate to a page on that server (I see GET request with full URI with all parameters).
However, if I’m using a form that submits request to a server:
<FORM action="http://192.168.1.107:8080/testaction" method="post">
<INPUT type="text" name="textfield" /><BR>
<INPUT type="submit" value="Send"/>
</FORM>
I only get the action in the URI (like “/testaction”). I cannot figure out how to get the actual data of the POST request.
Here is the part that handles the request in java code:
public class HomePageHandler implements HttpRequestHandler {
...
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext httpContext) throws HttpException, IOException {
String uriString = request.getRequestLine().getUri();
Uri uri = Uri.parse(uriString);
...
}
I realize I could be doing something wrong in java and/or HTML form itself. Please advise on both.
To get the POST body, you can do this: