WebServerSample form posting

Jun 5, 2012 at 4:19 PM

Is there a good example on how to handle form post/get requests? I'm using the WebServerSample in the latest trunk and it has the OnRequest. It throws the post request fine, and i can write out the response (e.response.body.write(...)) but it shows a 404 file not found error, and if i point it towards a real file, the Server.RequestReceived event isn't thrown

 

Thanks

TopHat

Aug 9, 2012 at 7:48 PM

Ever figure out the answer this this question?  Would LOVE to know.

Developer
Aug 10, 2012 at 8:15 AM

Usually a request will be handled by a server module. The OnRequest event is like a last resort - it only gets fired if no module could handle the request.

The behavior described by the op can be explained as following:

  1. Click on form submit button in browser
  2. Browser sends POST request for "http://127.0.0.1/formtest"
  3. Server tries to handle request checking all registered modules
  4. No module is found: server fires OnRequest event
  5. Server sends 404 error

Even if you set the IsHandled property to true, the 404 will be shown. This means, you should always have a module handling your request (sounds reasonable).

Now if you change the forms action to point to a uri which the server can handle, everything is fine. You could for example use PHP for this, see http://wo80.hostingsociety.com/p/httpserver.addons/