我刚刚浏览完SPDY 白皮书,现在我有兴趣尝试一下。我了解Google 正在使用 SPDY 通过 SSL 向 Chrome 提供内容。
在 SPDY 上设置和提供基本的“Hello world”HTML 页面的最简单方法是什么?
我刚刚浏览完SPDY 白皮书,现在我有兴趣尝试一下。我了解Google 正在使用 SPDY 通过 SSL 向 Chrome 提供内容。
在 SPDY 上设置和提供基本的“Hello world”HTML 页面的最简单方法是什么?
运行现有的 spdy 服务器,例如:
似乎最快和最简单的方法是按照此处的说明进行操作。
我用 C 编写了spdylay SPDY 库,最近添加了 Python 包装器python-spdylay。它需要 Python 3.3.0(在撰写本文时为 RC1),但您可以像这样编写简单的 SPDY 服务器:
#!/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()
SPDY 的目的是它对您的 Web 应用程序完全透明。你不需要编写代码来使用 SPDY,你只需要使用一个支持它的网络服务器。
如果您有一个 java web 应用程序,那么您可以使用 Jetty 启用 SPDY。3 个简单的步骤:将一个 jar 添加到启动路径以启用 NPN,为您的服务器创建 SSL 证书,将 SPDY 配置为连接器类型。见http://wiki.eclipse.org/Jetty/Feature/SPDY
这在 Jetty-9 中会更容易