如何在Ruby中使用TCPSocket創建POST請求?有沒有特別的格式來發布帖子?我有以下的,但我得到一個語法錯誤(這是爲Rails服務器):(紅寶石)ruby套接字:如何創建POST請求?
require 'socket'
s = TCPSocket.open("localhost", 3000)
s.puts("POST /<controller>/<action> HTTP/1.1")
s.puts("Host: localhost:3000")
s.puts("Content-Type: application/x-www-form-urlencoded")
s.puts("Content-Length: 103\r\n\r\n")
初次腮紅看起來不錯。我認爲和是佔位符,你真的發佈適當的值...你真的跟進103字節的數據? –
2009-11-27 02:31:01