2011-06-06 2 views

Répondre

1

j'ai écrit spdylay bibliothèque SPDY en C et a récemment ajouté Python wrapper python-spdylay. Il a besoin Python 3.3.0 (qui est RC1 au moment de cette écriture), mais vous pouvez écrire simple serveur SPDY comme ceci:

#!/usr/bin/env python 
import spdylay 

# private key file 
KEY_FILE='server.key' 
# certificate file 
CERT_FILE='server.crt' 

class MySPDYRequestHandler(spdylay.BaseSPDYRequestHandler): 

    def do_GET(self): 
     self.send_response(200) 
     self.send_header('content-type', 'text/html; charset=UTF-8') 

     content = '''\ 
<html><head><title>SPDY</title></head><body><h1>Hello World</h1> 
</body></html>'''.encode('UTF-8') 

     self.wfile.write(content) 

if __name__ == "__main__": 
    HOST, PORT = "localhost", 3000 

    server = spdylay.ThreadedSPDYServer((HOST, PORT), 
             MySPDYRequestHandler, 
             cert_file=CERT_FILE, 
             key_file=KEY_FILE) 
    server.start() 
0

L'intention de SPDY est qu'il est tout à fait transparente à votre application Web. Vous n'avez pas besoin d'écrire du code pour utiliser SPDY, il vous suffit d'utiliser un serveur web qui le supporte.

Si vous avez une application web java, alors vous pouvez activer SPDY en utilisant Jetty. 3 étapes simples: ajoutez un jar au chemin d'amorçage pour activer NPN, créez un certificat SSL pour votre serveur, configurez SPDY comme type de connecteur. Voir http://wiki.eclipse.org/Jetty/Feature/SPDY

Ce sera encore plus facile dans Jetty-9