Page 5 of 9

Re: atomic web server threads

Posted: Mon Apr 15, 2024 8:37 am
by idle
PBJim wrote: Mon Apr 15, 2024 6:55 am Thanks very much Idle, there is the below code which won't compile, as it's attemping to put -1 into an unsigned .a

Code: Select all

  Structure ST
    a.a[256] 
  EndStructure  
  Static skiptable.ST 

[...]
    For i = 0 To 255
      Skiptable\a[i] = -1;
Line 520: Overflow error a 'ascii' (.a) value must be between 0 and 255
Thanks, replace it with 255, I'm still using pb 6.10 b6
I expected it to cast to unsigned

Re: atomic web server threads

Posted: Mon Apr 15, 2024 9:26 am
by PBJim
idle wrote: Mon Apr 15, 2024 8:37 am Thanks, replace it with 255, I'm still using pb 6.10 b6
Thanks, yes that's fixed it, it's working well.

Re: atomic web server threads

Posted: Mon Apr 15, 2024 9:33 am
by idle
PBJim wrote: Mon Apr 15, 2024 9:26 am
idle wrote: Mon Apr 15, 2024 8:37 am Thanks, replace it with 255, I'm still using pb 6.10 b6
Thanks, yes that's fixed it, it's working well.
Thanks for pointing it out.

Re: atomic web server threads

Posted: Tue Apr 16, 2024 1:17 am
by idle
tested on ubuntu 22.04, you might need to change ports to 8080 and 8081 to test.
also check that index.html is lower case

Re: atomic web server threads

Posted: Tue Apr 16, 2024 5:37 am
by skinkairewalker
tomorrow i’ll test on mac

Re: atomic web server threads

Posted: Wed Apr 17, 2024 10:19 am
by Caronte3D
I'm testing the Get/Post now and after some minor tweaks, it works nice :D
but...
Is there already implemented a way to use persistent variables by session/client?

I mean... by example:
I use Post to get the name of user then I use that variable name on next page refreshes (or another ones) without Post

Re: atomic web server threads

Posted: Wed Apr 17, 2024 12:51 pm
by idle
Caronte3D wrote: Wed Apr 17, 2024 10:19 am I'm testing the Get/Post now and after some minor tweaks, it works nice :D
but...
Is there already implemented a way to use persistent variables by session/client?

I mean... by example:
I use Post to get the name of user then I use that variable name on next page refreshes (or another ones) without Post
The get and post callbacks are a bit half baked at the moment as in they don't allow you to modify anything, they just let you read a request and while you have a map of parameters you also really need the ability to modify header fields so you can set cookies and such. I haven't really given it much thought yet. I do plan on adding a map of header fields which will also make the internal processing a bit easier and then you could set a cookie or add header fields.

This might be a useful reference
https://developer.mozilla.org/en-US/doc ... TP/Cookies

Re: atomic web server threads

Posted: Wed Apr 17, 2024 2:28 pm
by Caronte3D
Ok, ok...
I wasn't expecting a mature server like the big ones, but some things are essential.
I will wait until you advance more on this nice project, I would like to help you, but my web programing skills are near zero :?
Thanks again! :wink:

Re: atomic web server threads

Posted: Thu Apr 18, 2024 2:21 am
by idle
Caronte3D wrote: Wed Apr 17, 2024 2:28 pm Ok, ok...
I wasn't expecting a mature server like the big ones, but some things are essential.
I will wait until you advance more on this nice project, I would like to help you, but my web programing skills are near zero :?
Thanks again! :wink:
It won't be hard to add session state but it still needs a bit more thought.

I've been adding compression based on request and mime type which is a no brainer no point compressing something that's already compressed and fixed up some minor bugs.

Incidentally the server is now getting a B grade on https://tools.pingdom.com/ it's quite useful for testing relative load times from different locations.
http://atomicwebserver.com/index.html

Version 3.0.8b2
Added deflate

Re: atomic web server threads

Posted: Thu Apr 18, 2024 8:10 am
by Caronte3D
Nice! 8)
I just noticed you have a PayPal button on the atomic server page, so I'm donating a little to pay you for some coffees. :wink:

Re: atomic web server threads

Posted: Thu Apr 18, 2024 9:23 am
by Fred
Great website and project :D

Re: atomic web server threads

Posted: Thu Apr 18, 2024 1:13 pm
by idle
Caronte3D wrote: Thu Apr 18, 2024 8:10 am Nice! 8)
I just noticed you have a PayPal button on the atomic server page, so I'm donating a little to pay you for some coffees. :wink:
Thanks, there's still a lot to do but its a good start, I will look into adding the session stuff next.
Fred wrote: Thu Apr 18, 2024 9:23 am Great website and project :D
Thanks, there's sill a bit to do, like TLS and the virtual file system / cache in memory keypair store but they will be optional plugins and maybe it will inspire you to add a libreSSL build to the pb libs once you see it all working.

Re: atomic web server threads

Posted: Fri Apr 19, 2024 1:10 pm
by sec
idle wrote: Thu Apr 18, 2024 1:13 pm
Caronte3D wrote: Thu Apr 18, 2024 8:10 am Nice! 8)
I just noticed you have a PayPal button on the atomic server page, so I'm donating a little to pay you for some coffees. :wink:
Thanks, there's still a lot to do but its a good start, I will look into adding the session stuff next.
Fred wrote: Thu Apr 18, 2024 9:23 am Great website and project :D
Thanks, there's sill a bit to do, like TLS and the virtual file system / cache in memory keypair store but they will be optional plugins and maybe it will inspire you to add a libreSSL build to the pb libs once you see it all working.
Add load balance, reverse proxy … we will get rid nginx … :p

Re: atomic web server threads

Posted: Fri Apr 19, 2024 10:02 pm
by idle
I just don't know how I'll do it yet

Re: atomic web server threads

Posted: Sat Apr 20, 2024 4:08 am
by idle
v3.0.8b3

Added header fields and cookies
Request header fields are read via map *request\RequestHeaders()
you can also add additional client Response headers via Atomic_Server_SetResponceHeader(*request.Atomic_Server_Request,key.s,value.s)

Cookies are extracted and mapped to *client\Cookies()
you can set cookies in a callback via
Atomic_Server_SetCookie(*request.Atomic_Server_Request,Cookie.s,value.s)

the cookies are available in callbacks to GET POST URIHandlers and Preprocessor functions

Code: Select all

Procedure URIfoo(*request.Atomic_Server_Request)
  
  Protected  *Atomic_Server.Atomic_Server = *request\serverid 
  Protected  *client.Atomic_Server_Client = *request\clientID 
  Protected  content.s,session.s,setsession.s   
  Protected *data
  
  If FindMapElement(*client\Cookies(),"sessionID")  
    session = *client\Cookies()
  Else   
    setsession = Str(Random($FFFFFFFF)) + "; " + "Max-Age=" + "60"  
    Atomic_Server_SetCookie(*request,"sessionID",setsession)
  EndIf  
  
  Debug *request\Request 
  
   content.s = "<!DOCTYPE html>" + #CRLF$
   content + "<html><head>" + #CRLF$
   content + "<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Noto Sans&effect=fire'>" + #CRLF$
   content + "<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Noto Color Emoji'>" + #CRLF$
   content + "<meta charset='utf-8' />" + #CRLF$
   content + "<title>" + *Atomic_Server\Title + "</title>" + #CRLF$
   content + "<style> body { background-color: #6600ff; margin: 10%;} h1 { font-family: 'Noto Sans', sans-serif; color: white;  text-align: center; } " + #CRLF$
   content + "p { font-family: 'Noto Sans', sans-serif; font-size: 18px;  text-align: center; color: white;} " + #CRLF$ 
   content + "h2 { font-family: 'Noto Color Emoji'; text-align: center; } " + #CRLF$ 
   content + "label { font-family: 'Noto Sans', sans-serif; font-size: 30px;  text-align: left; color: white;} " + #CRLF$ 
   content +  "input[type=text], Select { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } " + #CRLF$  
   content +  "input[type=submit] { width: 100%; background-color: #0099cc; color: white; padding: 14px 20px; margin: 8px 0; border: none; border-radius: 4px; cursor: pointer; } </style>"  + #CRLF$
   content + "</head><body><h1 class='font-effect-fire' style='text-align:center';>" + *Atomic_Server\Title + "</h1>"+ #CRLF$
   content + "<h2 style='text-align:center';>" + Atomic_Server_Chr($2622) + "</h2>"
   ForEach *request\parameters() 
    content + "<p>" + MapKey(*request\parameters()) + "=" + *request\parameters() +"</p>" 
   Next 
   If session <> ""
     content + "<p>" + "sessionID =" + session + "</p>"  
   EndIf 
   
   content + "<body></html>"
    
  *data = UTF8(content)
  
  *request\ContentType = "text/html" ;Set the contentType
  
  ProcedureReturn *data  
  
EndProcedure