I'm trying to connect to my test fcgi application via unix socket. The server is pretty simple and taken from flask documentation http://flask.pocoo.org/docs/0.10/deploying/fastcgi/
The client code is mine. I expect to send the sample HTTP request via socket.send
and and receive an HTTP response with "Hello World" into it. The problem is that client hangs up on s.recv(1024)
and nothing happens.
The server code:
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp, bindAddress="fcgi.sock").run()
The client code:
# -*- coding: utf-8 -*-
import socket
req = """GET / HTTP/1.1
Host: localhost\r\n\r\n"""
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.settimeout(1.0)
s.connect("fcgi.sock")
s.send(req)
data = s.recv(1024)
s.close()
print('Received ' + repr(data))
I tested to get response through the nginx, and it worked well, but I cannot to perform this using sockets. Does anyone know what is the problem with my client code?