[erlang-questions] httprequest using erlang

Kevin Scaldeferri <>
Fri Feb 13 16:46:13 CET 2009


Why don't you use one of the existing HTTP server implementations?

-kevin


On Feb 13, 2009, at 2:20 AM, Hynek Vychodil wrote:

> You should make HTTP response but you have made raw response  
> directly to socket.
>
> Try this
>
> gen_tcp:send(Socket, ["HTTP/1.0 200 OK\r\nContent-Type:text/plain\r\n 
> \r\nI Received ", Data]),
>
> On Fri, Feb 13, 2009 at 10:22 AM, prasantha kumara < 
> > wrote:
> Hi all!
> I am dealing with a erlang server which is accept http request from
> other frramework.i have sent a request to the server. following is the
> some code which i have used to do it.
>
> inet:setopts(Socket, [{active, once}]),
> receive
> % do something with the data you receive
> {tcp, Socket, Data} ->
> gen_tcp:send(Socket, "I Received " ++ Data),
>
>  but when it is recieved from the java it gives following error.
>
>
> The server 127.0.0.1 failed to respond with a valid HTTP response
>        at  
> org 
> .apache 
> .commons 
> .httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1846)
>        at  
> org 
> .apache 
> .commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java: 
> 1590)
>        at  
> org 
> .apache 
> .commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)
>        at  
> org 
> .apache 
> .commons 
> .httpclient 
> .HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
>        at  
> org 
> .apache 
> .commons 
> .httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java: 
> 170)
>        at  
> org 
> .apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 
> 396)
>        at  
> org 
> .apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java: 
> 324)
>        at httpRequest.Test.main(Test.java:24)
>
>
> Can any body help me to format the response correctly using erlang ?
>
> thanks
> prasantha.
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
>
> -- 
> --Hynek (Pichi) Vychodil
>
> Analyze your data in minutes. Share your insights instantly. Thrill  
> your boss.  Be a data hero!
> Try Good Data now for free: www.gooddata.com
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090213/ffb638c3/attachment.html>


More information about the erlang-questions mailing list