Hi Sean,

On 02 Mar 2014, at 06:49, Sean P. DeNigris <[email protected]> wrote:

> In porting the Mechanize web scraping library from Ruby, I started with the
> following example:
>  a.get('http://google.com/') do |page|
>    search_result = page.form_with(:name => 'f') do |search|
>      search.q = 'Hello world'
>    end.submit
> 
> It GETs
> http://www.google.com/search?ie=ISO-8859-1&hl=en&source=hp&q=Hello+world&gbv=1
> 
> I tried to do that with Zinc via formAt: name put:, but when I sent #get,
> the query was empty and the response was another blank search form. It took
> me some time to figure out what was going on and change to #queryPut:at: in
> the GET case, but now I'm managing form logic from the outside. Since GET is
> valid for forms (apparently it is the default per
> http://www.w3schools.com/tags/att_form_method.asp), it seems Zinc should
> handle this more gracefully. I would expect it to check for form fields and
> add them to the query when doing a GET. What do you think?

Cool that you are trying to do a project like that.

The reason this fails is because it is explicitly prevented in 
ZnClient>>#method:! If you go there and remove the whole #ifTrue:, sending 
entities with a GET and your example will work.

Making the change, one unit test fails ZnClientTest>>#testGetAfterPost and that 
is why the code is there: if you re-use a ZnClient instance (with its 
connection) to the same (REST) host, you are also re-using the request object, 
and then you don't want to carry over entities from a previous request. This is 
a feature that we use internally all the time.

I have to think about the best solution: like make this an option, and which 
would best be the default. I'll come back to you.

Thanks for the feedback,

Sven

> n.b. Gofer it
>       smalltalkhubUser: 'SeanDeNigris' project: 'Mechanize';
>       package: 'Mechanize';
>       load.
> 
> 
> 
> 
> 
> 
> 
> -----
> Cheers,
> Sean
> --
> View this message in context: 
> http://forum.world.st/Zinc-bug-submitting-form-via-GET-tp4747276.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
> 


Reply via email to