Goliath + PTTH
elcuervo opened this issue · comments
Currently I'm trying to implement a server which must respond in a PTTH fashion: Upgrading the connection and sending an HTTP request in the same socket.
How can I access the raw socket to send data after a response?
Thanks!
websocket handler does this, take a look there: https://github.com/postrank-labs/goliath/blob/master/lib/goliath/websocket.rb
Having said that, there are probably easier ways to do this.. take a look at streaming example: you can write directly to the socket once the headers are flushed.
You are right, using the streaming example is more clear.
But, if I need to read a response AFTER sending a response is there a way I can do that? Or I just need to implement similar to em-websocket?
You can define an on_data and stream the data in, and write the data out.. Once again, check the streaming example. :-) All the machinery is there.
You were right. I was writting and reading ok there was an error on the client I want to make the server compatible.
Thank you!