Sean, On 02 Mar 2014, at 12:44, Sven Van Caekenberghe <s...@stfx.eu> wrote:
> Hi Sean, > > On 02 Mar 2014, at 06:49, Sean P. DeNigris <s...@clipperadams.com> 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. In #bleedingEdge: === Name: Zinc-HTTP-SvenVanCaekenberghe.391 Author: SvenVanCaekenberghe Time: 2 March 2014, 7:19:50.045159 pm UUID: 39686b36-3c95-430f-9f2d-bfe3d8db00b9 Ancestors: Zinc-HTTP-SvenVanCaekenberghe.390 Added ZnClient #autoResetEntityMethods to control for which methods #resetEntity happens automatically (in #method:), the default being #(HEAD DELETE). This happened previously on GET as well, but that conflicted with the fact that web forms can be submitted using a GET with an entity body (thx Sean DeNigris); Removed all #asTimeStamp calls === Name: Zinc-Tests-SvenVanCaekenberghe.204 Author: SvenVanCaekenberghe Time: 2 March 2014, 7:20:38.944687 pm UUID: adf6fed8-b440-4517-8215-6184d5255725 Ancestors: Zinc-Tests-SvenVanCaekenberghe.203 Added ZnClient #autoResetEntityMethods to control for which methods #resetEntity happens automatically (in #method:), the default being #(HEAD DELETE). This happened previously on GET as well, but that conflicted with the fact that web forms can be submitted using a GET with an entity body (thx Sean DeNigris); Removed all #asTimeStamp calls === In particular, the new ZnClientTests>>#testGetForm functional unit test covers your case. Regards, Sven > 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.