[英]HTTP POST Data unreadable until client closes
我正在嘗試使用套接字在 ruby 中創建 web 服務器進行實驗,並且在客戶端關閉之前我無法從發布請求中獲取有效負載。 然后,當客戶端關閉時,我無法發回任何數據。
代碼:
require "socket"
server = TCPServer.new($HOST, $PORT)
client = server.accept
while true
puts client.gets
#Prints all headers and request but I don't see the actual payload (key=value) until the client disconnects.
end
通過使用if line.chomp.length == 0
來獲取數據的標題和client.read()
的結尾,我可以獲得數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.