Processing post requests to populate a web page impossible?

How is this done since there is no way to pass information taken from the request body in HandleURL to the session?

The only way I can see though this is for the API to require a token as a parameter which is used as a reference in an app-wide dictionary. While this is possible, it means we incur the overhead of issuing and managing unique tokens on a per-session basis. There are many sites which don’t support this means of integration.

The unique ID could also be in a request header.

As pointed out by Greg previously, if the client is a Web browser a cookie could be set and the browser asked to call back. However if the caller is another a web service setting a cookie probably won’t be allowed.

No, client-side cookies set by a server are not as easy as it seems because there could be multiple instances of an app in a browser, and there’s no way of knowing in HandleURL if the browser will allow cookies in the first place.

Something like this seems to work with my browser:

In the App Object:

Public Property UrlData as Dictionary

Sub Opening
   UrlData = New Dictionary
End Sub

Funtction HandleURL
   Dim strURLSessionID as String =   EncodeHex(Xojo.Core.Date.SecondsFrom1970.ToString)
   App.URLData.Value(URLSessionID) = Request.Body
   Response.Header("LOCATION") = "/?"+"URLSessionID="+strURLSessionID
   Response.Status = 302
   Return True
End Function

In the Session object:

Sub Opening
    dim strURLSessionID as string = URLParameter("URLSessionID")
    dim strRequestBody as string = app.URLData.Value(strURLSessionID)
End Sub

It assumes a single Xojo Web instance for shared storage. Files or database storage would be needed over multiple cores.

1 Like

That also assumes that you only get one connection per second. If you need more, you might try Microseconds or Ticks instead of Xojo.Core.Date.SecondsFrom1970.


Seconds from 1970 returns a decimal with 3 places on Linux so it’s milliseconds I think.