Hi
I have an HTML form submitted to my B4J web server and I need to dump the full HTTP request for logging purposes, including the x-www-form-urlencoded payload.
The form is POST-ed to a URL containing query parameters (e.g. https://my.server.online/sample.html?id=12345&type=flat) as well as additional key/value parameters in the request payload.
Using req.FullRequestURI returns the full URL including the query parameters, however the payload is not present.
I tried req.InputStream and it actually contains the payload:
...however after this is executed I can't read anymore the parameters from the payload using req.GetParameter as they become empty.
On the contrary, if req.InputStream is used after req.GetParameter to read the payload, the stream would be empty as well.
In summary, reading the payload with both req.InputStream and req.GetParameter does not seem possible as they are mutually exclusive.
Am I doing something wrong?
Any other suggestion in addition to read the InputStream and parse the payload instead of using GetParameter ?
Thanks
Andrea
I have an HTML form submitted to my B4J web server and I need to dump the full HTTP request for logging purposes, including the x-www-form-urlencoded payload.
The form is POST-ed to a URL containing query parameters (e.g. https://my.server.online/sample.html?id=12345&type=flat) as well as additional key/value parameters in the request payload.
Using req.FullRequestURI returns the full URL including the query parameters, however the payload is not present.
I tried req.InputStream and it actually contains the payload:
B4X:
'Parse payload
Dim data() As Byte = Bit.InputStreamToBytes(req.InputStream)
Dim payload As String = BytesToString(data, 0, data.Length, "UTF8")
Log("Payload: " & payload)
...however after this is executed I can't read anymore the parameters from the payload using req.GetParameter as they become empty.
On the contrary, if req.InputStream is used after req.GetParameter to read the payload, the stream would be empty as well.
In summary, reading the payload with both req.InputStream and req.GetParameter does not seem possible as they are mutually exclusive.
Am I doing something wrong?
Any other suggestion in addition to read the InputStream and parse the payload instead of using GetParameter ?
Thanks
Andrea