|
Re: HTTP POST request problems with RAP 2.0 [message #1097236 is a reply to message #1095845] |
Thu, 29 August 2013 12:24 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
since RAP 2.0 there is strict separation between GET and POST request.
GET request always delivers the initial HTML page, POST request always
returns JSON protocol message [1]. The input (body of the request) for
the POST requests must be JSON protocol message as well. Your POST
request contains "application/x-www-form-urlencoded" data, which is
incorrect (in RAP 2.1SR1/2.2M1 POST request without "application/json"
content-type are marked as bad requests - HTTP 400).
[1] http://wiki.eclipse.org/RAP/Protocol
[2] http://eclipsesource.com/blogs/2013/02/01/rap-2-0-countdown-15/
HTH,
Ivan
On 8/27/2013 9:02 PM, Hsinlun Lee wrote:
> Hi everyone,
>
> We are trying to upgrade our application from RAP 1.3 to RAP 2.0 and having problems with HTTP POST method. We reproduced the issue by sending a HTTP POST request with a test parameter from JMeter to the RAP mail template project (RAP 2.1) that comes with Eclipse Kepler (please see the stack trace attached below).
>
> This is basically what happens. In org.eclipse.jetty.server.Request right after the server receives an HTTP request (either POST or GET), it calls extractParameters() to read all the parameters which calls getInputStream() to read from HTTP request. It then sets _inputState = _STREAM. Later on it calls handlePostRequest( request, response ), which eventually calls request.getReader(). In getReader(), it checks _inputState flag and throws an IllegalStateException of STREAMD.
>
> I think this is happening because it calls both getInputStream() and getReader(). We deployed the war on Tomcat 7, and have got a similar result. It works with HTTP GET but not POST. It works for both on RAP 1.3.
>
> Is this a bug or did we miss something here?
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Re: HTTP POST request problems with RAP 2.0 [message #1097439 is a reply to message #1097399] |
Thu, 29 August 2013 18:29 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
could you elaborate a little bit about your use case? Why you want to
compose a JSON protocol message manually. The protocol message is
created and sent with a POST request to the server by the client. RAP
application is always started with GET request. If you want to send
initial startup parameters to your application do it in the GET request:
http://127.0.0.1:8080/my_servlet_path?param1=value1
These parameters will be sent automatically with the first POST request
like:
{
|"head":{"rwt_initialize":true,"queryString":"param1=value1"},
"operations":|
...
}
Than you can get this parameter on the server-side as usual:
request.getParameter( "param1" );
HTH,
Ivan
On 8/29/2013 8:04 PM, Hsinlun Lee wrote:
> Ivan,
> Thank you for the reply. Could you please show me an example of
> posting parameters to the server?
> Here is what I have tested, but I got HTTP 403 back from the server
> without seeing any exception in the console.
> Thank you.
>
> HTTP POST body:
> {
> "head" : { "parameter" : "value" },
> "operations": [ ]
> }
>
> Response:
> {"head":{"error":"session timeout"},"operations":[]}
>
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Re: HTTP POST request problems with RAP 2.0 [message #1097529 is a reply to message #1097463] |
Thu, 29 August 2013 21:17 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
one possible solution will be to store all parameter (sensitive
information) in a REST service before starting the RAP application. The
REST service will return a key, which you will put it in the first RAP
application GET request as a parameter. When application starts the
information stored into the REST service could be retrieve (based on
this key).
If you think that starting RAP application with POST request is useful,
please open an enhancement request.
Best,
Ivan
On 8/29/2013 10:12 PM, Hsinlun Lee wrote:
> Ivan,
> Thank you for the quick reply. In our use case, we have to send huge
> amount of data including user security context, user preferences,
> system configuration... The data we are sending exceeds what most
> servers/clients can support. We are currently using HTTP POST method
> to get around this in our RAP 1.3 application.
>
> Please advise how we can implement this in RAP 2.0. Thank you.
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Powered by
FUDForum. Page generated in 0.03851 seconds