View Full Version : [FIXED] HttpProxy always uses POST
4 Sep 2008, 12:44 PM
Everytime I use an HttpProxy where the RequestBuilder is configured to use RequestBuilder.GET method it always uses a post.
Here is sample code:
String url = "http://localhost:3001/lamps/1/";
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
HttpProxy<Object, PagingLoadResult<ModelData>> proxy = new HttpProxy<Object, PagingLoadResult<ModelData>>(rb);
XmlReader<PagingLoadConfig> reader = new XmlReader<PagingLoadConfig>(Lamp.getModelType())
protected ListLoadResult newLoadResult(PagingLoadConfig loadConfig, List<ModelData> models)
PagingLoadResult result = new BasePagingLoadResult(models, loadConfig.getOffset(), loadConfig.getLimit());
PagingLoader loader = new BasePagingLoader(proxy, reader);
Ok, now I'm really convinced there is a problem. Looking at HttpProxy source code you essentially see a more complex version of this:
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "http://localhost/");
Request request = rb.sendRequest("&sortfield=null&sortdir=none&start=0&limit=50", new SomeRequest());
catch (Exception ex)
The previous code will POST every single time. Remove the first parameter in the sendRequest call and it will then GET.
Darryl, why not just create your own RequestBuilder internal to HttpProxy? And then appropriately configure it based upon a GET/POST and the URL?
Darryl, any thoughts on this issue?
8 Sep 2008, 6:51 PM
I have tested HttpProxy and it respects the request builder request type. How are you testing this behavior?
Thanks for your response. In my first post in this message thread I used that snippet of code. I was then able to break down the problem and reproduce the error using just RequestBuilder in my last snippet of code in this thread. I tested both of these in Hosted mode.
Did you try both snippets of code in Hosted mode?
I believe the proper implementation for GET parameters is to append them to the URL of the RequestBuilder, where as maybe POST parameters should be passed in the first parameter of the sendRequest method?
Most tutorials demonstrate GET requests this way:
http://tycoon.hpl.hp.com/browser/src/grid/hadoop/gwt/src/com/hp/hpl/tycoon/ui/thundercloud/client/Tycoon.java?rev=1604%3A1e0a722582e5 [Line 149]
I just believe your implementation to be wrong. Like I said, the tutorials show that would be the case. Why not create RequestBuilder internally to HttpProxy? And then for the HttpProxy constructor you could just specify the URL, URL params for POST, and then use an enum for POST/GET request type.
Again, I could be wrong... but using the two snippets a of code post previously you should be able to replicate the problem. Thanks again for your time.
9 Sep 2008, 5:10 PM
Yes, you are correct. I was testing in FF. IE always does a post. HttpProxy now passes null for POST requests. Fix is in SVN.
10 Sep 2008, 9:23 AM
I assume you mean it passes null for GET requests? Also, will this then work for the PagingToolbar? IE: Will the PagingToolbar then append it's parameters to the URL if it's GET and if it's POST send them in the request?
11 Sep 2008, 7:21 AM
Yes and Yes.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.