Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read http body in Woo

I am trying to write a server with Woo. I need to handle HTTP body sent by:POST method. However, I don't know how to read the body.

In env, there are :RAW-BODY and :CLACK.IO look like somewhere to read body from. But I have no clue how to read it. No documents in repo and I searched on google and looks like everyone just gives examples of giving a response to client rather than read HTTP body.

Can anyone help me?

like image 223
ccQpein Avatar asked Dec 14 '25 21:12

ccQpein


1 Answers

I check FLEXI-STREAMS package and figure out VECTOR-INPUT-STREAM (the type of :raw-body) can read by read-byte, and read-sequence.

So the solution is sort of:

(let ((a (make-array 11 :element-type '(unsigned-byte 8))))
      (read-sequence a (getf env :raw-body))
      (format t "~a" a))
like image 139
ccQpein Avatar answered Dec 16 '25 23:12

ccQpein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!