HandleURL and concurrent access

Hypothesis:
I have a standalone webapp with a code into the app.HandleURL event; this code requires 2 seconds to be executed.
At 12:00:00, my app receives a connection; the code start its execution and it will be terminated at 12:00:02.
At 12:00:01, my app receives another connection; now what’s happen? This request wait till the first request will be terminated or this request will be executed in parallel with the first one?

Ciao Pietro,
It will work in parallel

Grazie Antonio

…and now another question.

If I get some data into the app.HandleUrl from the app.HandleURL.Request.entity or app.HandleURL.Request.QueryString, how can I pass them to the session?

It depends which Session you are talking about since there could be several at any given time.

  • you could iterate through them using App.SessionCount and SessionAtIndex
  • you could use a WebThread from a Session to pull the data from a buffer

[quote=310749:@Greg O’Lone]It depends which Session you are talking about since there could be several at any given time.

  • you could iterate through them using App.SessionCount and SessionAtIndex
  • you could use a WebThread from a Session to pull the data from a buffer[/quote]

The code in my App.HandleURL can generate 2 results:
If the request is only for data, it responds like a webservice and there will not be any session.

Request.Print "my response as webservice style"
Return True

If the request is for a page, I have to start a session and show a page using the data coming from the app.WebRequest.
So I can’t use your first suggestion, because in the App.HandleURL there isn’t the session yet.
I think I could use your second suggestion (WebThread), but I don’t know how to use it. Is there any example in the xojo’s documentation to take a look?

Simply redirect the user to the app with JavaScript Location. If you need some parameters about the user add them to the URL so you can read them in Session.

I do it with an hash.
Sending Request.Print "<html><head><script>location='http://0.0.0.0#"+hash+"'</script></head><body><a href=""http://0.0.0.0#"+hash+""">klick</a></body></html>"

With some code in session.open I use me.HashTag to get same data into the session

“Parallel” would imply that the app could do more than one thing at a time, it cannot.

If during the processing of request #1 the framework has opted to yield to another thread then the appearance of handling two requests simultaneously might occur. All that would really happen is the processing of #1 would take longer than necessary because of #2.

Or just use a redirect.

request.header("Location") = "http://your.domain.name/" Request.Status=302 Return True