ChanServ changed the topic of #picolisp to: PicoLisp language | Channel Log: https://irclog.whitequark.org/picolisp/ | Check also http://www.picolisp.com for more information
orivej has quit [Ping timeout: 250 seconds]
patrixl has quit [Quit: Leaving.]
patrixl has joined #picolisp
orivej has joined #picolisp
orivej has quit [Ping timeout: 256 seconds]
<tankf33der> i would like write my own ix.io, how i feel it should be. for code sharing. on picolisp.
<Regenaxer> That's a good idea
orivej has joined #picolisp
<tankf33der> Regenaxer: how can i get documentation for get and post requests?
<tankf33der> it was variable *Post or something
<Regenaxer> yes, *Post
<Regenaxer> and in form gui also *PRG
<Regenaxer> (post redirect get)
<Regenaxer> I use *PRG usually
<tankf33der> how can i get uri part if called / or /mike or /mike22
<tankf33der> ?
<Regenaxer> You can analyze the *Url global
<tankf33der> i knew it
<tankf33der> :)
<Regenaxer> :)
<tankf33der> how to echo /etc/issue on get request correctly?
<Regenaxer> Just (in "/etc/issue" (echo))
<Regenaxer> but you need the header better
<tankf33der> i see
<Regenaxer> I look for an example
<Regenaxer> If stand-alone (not in another page output), do
<Regenaxer> (httpHead "text/plain; charset=utf-8") (ht:Out *Chunked (in ... (echo)
<tankf33der> insane, impossible without you.
<Regenaxer> You can do it, just take time
stultulo has joined #picolisp
f8l has quit [Ping timeout: 256 seconds]
stultulo is now known as f8l
<tankf33der> you looked example of what?
<Regenaxer> lib/form.l
<tankf33der> ok
<tankf33der> how to reply ok on / and mike11 ?
<tankf33der> and /mike11
<Regenaxer> For just on / start with (server <port> "!mike11"), allow "!mike11", and code (de mike11 () (echo ...
<Regenaxer> mike11 is difficult, can be done with httpGate if the app name is mike11
<Regenaxer> In general, only files *.l and !functions are executed directly
<tankf33der> aaaaaa
<tankf33der> ok
<tankf33der> how to handle any part after /
<tankf33der> pastebin should handle different names of pastes after /
<tankf33der> on /mike1 echo file mike1 if exists
<Regenaxer> For a pil server, you need to separate args with "?" and "&"
<Regenaxer> This won't work
<Regenaxer> The direct path is the file.l to execute
<Regenaxer> mike11 is the app name
<Regenaxer> as in httpGate configured
<Regenaxer> If you want to interpret the url differently, ymu need to modify @lib/http.l
<tankf33der> but i wanted get /mike11 or /mike22 to file.l
<tankf33der> yea
<tankf33der> ok
<Regenaxer> there is 1 way
<Regenaxer> if mike11 is a directory
<Regenaxer> you can put a file "default" there
<Regenaxer> it will be 'load'ed
<tankf33der> what function i should check in http.l to modify behavier?
<Regenaxer> First try the "default" way
<Regenaxer> nothing needs to be modified
<tankf33der> i think this is not ok
<Regenaxer> eg I have a directory "robots.txt"
<tankf33der> remember ix.io site?
<Regenaxer> or favicon.ico/
<tankf33der> it returns just url http://ix.io/zxcv
<Regenaxer> yeah
<Regenaxer> you need to return http://ix.io?zxcv
<tankf33der> so zxcv is just a file to echo on get request
<Regenaxer> t
<Regenaxer> eg the wiki: https://picolisp.com/wiki/?home
<Regenaxer> home is the argument
<tankf33der> make sense, trying
<Regenaxer> in fact, http://ix.io/zxcv *might* work
<Regenaxer> but you must allow everything
<Regenaxer> The server echoes zxcv
<Regenaxer> So no code at all needed
<Regenaxer> But how to disallow stuff then?
<Regenaxer> You could make all files start with "z" and allow only that
<beneroth> whitelisting is the right strategy, blacklisting is wrong sense of security
* beneroth mumbles just some general nitbits...
<Regenaxer> I know ;) depends
<Regenaxer> 'allow' is whitelisting
<Regenaxer> (allowed ("z"))
<Regenaxer> Anyway, host?arg is the clean way
<tankf33der> in what asteriks variable will be arg then ?
<Regenaxer> It is passed, just as to a function
<Regenaxer> 'script'
<Regenaxer> (server (or (format (sys "PORT")) *WikiPort) "!wiki") )
<Regenaxer> (de wiki (Nm)
<tankf33der> http://ix.io?zxcv
<tankf33der> i would like this form
<tankf33der> shorter as possible
<Regenaxer> yes, good
<Regenaxer> So the default function passed to 'server' will get it
<Regenaxer> Just like the wike example
<Regenaxer> In https://picolisp.com/wiki/?home the "wiki" is the app name in httpGate
<Regenaxer> if you have only a single app on the server, it is not needed
<tankf33der> pil @lib/http.l @lib/xhtml.l @lib/form.l --server 8080 pastebin.l +
<Regenaxer> i.e. if it is the default app
<Regenaxer> "@" in the config of httpGate
<tankf33der> i started file pastebin.l like this
<Regenaxer> yes, good
<tankf33der> and thought i could get arguments in (next) call :)
<Regenaxer> so pastebin.l receives the arg with (next)
<tankf33der> really ?
<Regenaxer> yep :)
<tankf33der> and (echo (next)) i get nothing back
<Regenaxer> (msg (next))
<Regenaxer> or (ht:Prin (next)) or just (prinl (next))
<Regenaxer> I meant (msg (next)) just to see something
<Regenaxer> or in your case (in (next) (echo))
<Regenaxer> or better (let F (next) (if (info F) (in F (echo)) (... error ...]
<tankf33der> orgasm.
<Regenaxer> :)
razzy` has quit [Ping timeout: 256 seconds]
<tankf33der> now post
<tankf33der> curl -F "f=/etc/issue" ix.io
<Regenaxer> You could just use "post"
<Regenaxer> and check that in pastebin.l
<Regenaxer> i.e. a special, reserved file name
<tankf33der> ix.io/?post
<tankf33der> like this ?
<Regenaxer> yes
<Regenaxer> or have a separate server
<Regenaxer> named "post" in httpGate
<Regenaxer> then just ix.io/post
<Regenaxer> Storing and fetching can be different programs then
<tankf33der> i dont want httpGate, for example because i dont know why i need it
<tankf33der> as minimal as possible
<Regenaxer> you need it for TLS
<Regenaxer> and you get names for the programs
<Regenaxer> otherwise ix.io/?post is fine
<tankf33der> ok
<Regenaxer> or, better, NO arg means "post" :)
<Regenaxer> extreme minimal :)
<tankf33der> curl -F f=@/etc/issue 127.0.0.1:8080/?post
<tankf33der> *Post is T
<Regenaxer> Not sure what curl does here
<tankf33der> ix.io gets content of file issue
<Regenaxer> You don't want the NO arg way?
<Regenaxer> (ifn (next) ...
<Regenaxer> you can get files 2 ways. Either in a stream in GET, or in multipart in POST
<tankf33der> curl -F is multipart
<Regenaxer> great
<tankf33der> but how get content of f
<tankf33der> in curl -F f=@/etc/issue
<tankf33der> ?
<Regenaxer> It is in (tmp )
<Regenaxer> and the name is in 'Var'
<Regenaxer> as 'f' is not a global, it is in the 'http' property
<Regenaxer> (get 'f 'http)
<tankf33der> content of 'f got
<tankf33der> cant get content of issue
<tankf33der> curl -F f=@/etc/issue
<tankf33der> curl -F f=issue
<Regenaxer> yes
<Regenaxer> (tmp "issue")
<tankf33der> i get always "issue" in (get 'f 'http)
<Regenaxer> T
<Regenaxer> The server is not allowed to write to an absolute path
<Regenaxer> /etc/
<tankf33der> (msg 'Post *Post (tmp (get 'f 'http)))
<tankf33der> i get
<tankf33der> PostT/home/mpech/.pil/tmp/350512/issue
<tankf33der> and no file in this path
<Regenaxer> no, 'msg' is different
<Regenaxer> The first arg as a Lisp object
<Regenaxer> the rest is 'pack'ed
<tankf33der> i meant no file in OS
<tankf33der> on OS level
<Regenaxer> (msg (tmp (get 'f 'http)) "Post " *Post)
<Regenaxer> It is in tmp/35013/issue
<Regenaxer> relative to the CWD
<tankf33der> total 0
<tankf33der> [mpech@lambda tmp]$ ls -l
<tankf33der> [mpech@lambda tmp]$ pwd
<tankf33der> [mpech@lambda tmp]$
<tankf33der> /home/mpech/.pil/tmp
<tankf33der> empty.
<Regenaxer> Just do (in (tmp (get 'f 'http) (echo)))
<Regenaxer> hmm
<tankf33der> yeas
<tankf33der> uea
<tankf33der> yes
<tankf33der> no file.
<Regenaxer> ah
<Regenaxer> yes
<Regenaxer> the process 35013 is gone, right? :)
<Regenaxer> No session
<Regenaxer> You must handle as above
<Regenaxer> (in (tmp (get 'f 'http) (echo)))
<Regenaxer> plus sanity checks of course
<tankf33der> how to print back to shell on curl call ?
<tankf33der> now im getting this:
<tankf33der> $ curl -F "f=@/etc/issue" 127.0.0.1:8080/?post
<tankf33der> curl: (1) Received HTTP/0.9 when not allowed
<Regenaxer> You should respond to the client
<Regenaxer> Just call (respond) in the end
<tankf33der> the same
<Regenaxer> What is HTTP/0.9 ??
<tankf33der> unknown
<tankf33der> got it
<Regenaxer> btw, "print back to shell" is (respond "OK")
<tankf33der> (respond "mike\n")
<tankf33der> $ curl -F "f=@/etc/issue" 127.0.0.1:8080
<tankf33der> mike
<tankf33der> perfect.
<Regenaxer> :)
<tankf33der> what you meant by
<tankf33der> 14:43 <Regenaxer> plus sanity checks of course
<tankf33der> ?
<tankf33der> file size? content? mime?
<Regenaxer> yes, not empty
<Regenaxer> and no slashes in name perhaps
<Regenaxer> no, slashes should be gone already
<Regenaxer> it does (stem L "/" "\\")
<tankf33der> now i got all required blocks and could build a house.
<Regenaxer> cool
<tankf33der> cry of happiness
<beneroth> congrats, have fun :)
<Regenaxer> :)
<tankf33der> Regenaxer:
<tankf33der> question
<tankf33der> If i already set
<tankf33der> (httpHead "text/plain; charset=utf-8")
<tankf33der> and could echo file
<tankf33der> how to print message for example, "File not found" if file dont exist?
<Regenaxer> This must be done before he header
<Regenaxer> ht404 ?
<Regenaxer> no
<Regenaxer> (http404)
<tankf33der> i see
<tankf33der> works.
<tankf33der> get functionality done, now post.
<tankf33der> eh.
<tankf33der> done.
<tankf33der> i will write documentation, index.txt and post announce.
<Regenaxer> Good!
<tankf33der> Implement everything i wanted.
<Regenaxer> Do you encrypt the files?
<Regenaxer> blake
<tankf33der> no, taking hash
<tankf33der> hash is 4 bytes
<tankf33der> first and second byte is part of dir in *DirRoot
<Regenaxer> ah
<tankf33der> also i would like mention nginx in from of pil in documebtation
xkapastel has joined #picolisp
<Regenaxer> PLIO implemented
<tankf33der> uh.
<tankf33der> i will post pastebin service to ML and reddit
<tankf33der> in general its ok, right ?
<Regenaxer> yes, looks good
<tankf33der> thanks a lot.
<beneroth> very nice, thanks tankf33der !
alexshendi has joined #picolisp
<alexshendi> Hi!
<beneroth> hi alexshendi o/
<alexshendi> Hi, beneroth: \0/
<beneroth> how are you?
<Regenaxer> Hi alexshendi!
<alexshendi> Hi Regenaxer, how is life?
<alexshendi> Well, actually I'm fine, given the situation. I'm a little bit bored and feel fenced in, but these are first world problems, as they say.
<Regenaxer> Good :)
xkapastel has quit [Quit: Connection closed for inactivity]
<alexshendi> And how are you all?
<Regenaxer> All fine as far as I can see
<beneroth> aye
<alexshendi> Good :)
<beneroth> now you got time for picolisping, alexshendi ?
<beneroth> :)
<alexshendi> Good night :)
alexshendi has quit [Quit: leaving]
orivej has quit [Ping timeout: 256 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 265 seconds]