Estoy intentando publicar algunos datos en un servidor en Haskell y el lado del servidor está vacío.Contenido HTTP POST en Haskell
Estoy utilizando la biblioteca Network.HTTP para la solicitud.
module Main (main) where
import Network.URI (URI (..), parseURI, uriScheme, uriPath, uriQuery, uriFragment)
import Network.HTTP
import Network.TCP as TCP
main = do
conn <- TCP.openStream "localhost" 80
rawResponse <- sendHTTP conn updateTest
body <- getResponseBody rawResponse
if body == rqBody updateTest
then print "test passed"
else print (body ++ " != " ++ (rqBody updateTest))
updateURI = case parseURI "http://localhost/test.php" of
Just u -> u
updateTest = Request { rqURI = updateURI :: URI
, rqMethod = POST :: RequestMethod
, rqHeaders = [ Header HdrContentType "text/plain; charset=utf-8"
] :: [Header]
, rqBody = "Test string"
}
Esta prueba está devolviendo la cadena vacía como el cuerpo de la respuesta del servidor, cuando yo creo que debe ser eco del mensaje "cadena de prueba".
que lo ideal sería replicar la funcionalidad de:
curl http://localhost/test.php -d 'Test string' -H 'Content-type:text/plain; charset=utf-8'
y estoy validando los resultados con prueba.php serverside:
<?php
print (@file_get_contents('php://input'));
estoy haciendo esto mal o debo estar intentando otra ¿biblioteca?
Sugiero probar y oler la comunicación usando "wireshark" o un programa similar para ver el contenido real que se envía/recibe. esto te señalará el problema mucho mejor – yairchu