Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlighting to README #1

Merged
merged 1 commit into from Jul 1, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 22 additions & 21 deletions README.md
Expand Up @@ -5,32 +5,33 @@ python-spdy is a simple spdy parser/(de)muxer for python >= 2.7 (including 3.x).

usage
-----
```python

import spdy, spdy.frames

#with an existing socket or something
context = spdy.Context(side=spdy.SERVER, version=2)
import spdy, spdy.frames

while True:
data = sock.recv(1024)
if not data:
break
#with an existing socket or something
context = spdy.Context(side=spdy.SERVER, version=2)

context.incoming(data)
while True:
data = sock.recv(1024)
if not data:
break

while True:
frame = context.get_frame()
if not frame:
break

if isinstance(frame, spdy.frames.Ping):
pong = spdy.frames.Ping(frame.ping_id)
context.put_frame(pong)

outgoing = context.outgoing()
if outgoing:
sock.sendall(outgoing)
context.incoming(data)

while True:
frame = context.get_frame()
if not frame:
break

if isinstance(frame, spdy.frames.Ping):
pong = spdy.frames.Ping(frame.ping_id)
context.put_frame(pong)

outgoing = context.outgoing()
if outgoing:
sock.sendall(outgoing)
```
installation
------------

Expand Down