This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside MyHTTPRequest.m | |
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response { | |
/* This delegate method is called before the connection sends a NSURLRequest. | |
(NSURLResponse *)response will be nil when this method is not called by the delegate recieving a redirect | |
(NSURLRequest *)request will contain the NSURLRequest object that (NSURLConnection *)connection is about | |
to send to the server. | |
For example, during an initial request to a server, this delegate method is called | |
and (NSURLResponse *)response will be nil, since the delegate has not received a HTTP | |
redirect ( the delegate has not received any response from the server yet because no request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MyHTTPRequest.h | |
@interface MyHttpRequest : NSObject { | |
// The following 3 class attributes are saved as the initial request is created. | |
// If a redirect occurs, these attributes will be used to copy to the last redirected request, | |
// only if the URL is the same as the initial request's URL | |
NSData *requestBodyData; | |
NSString *requestMethod; // POST or GET | |
NSURL *requestURL; // initial request's URL | |
// other attributes omitted | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if the client request does not contain a valid session id, the | |
# client will receive a redirect to http://10.0.0.2/signin/ | |
@login_required(login_url='/signin/') | |
def user_home_view(request): | |
# . . . returns the user's home view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def auth_landing_page(request): | |
try: | |
if request.META['HTTP_AUTHORIZATION']: | |
# in httpd.conf set 'WSGIPassAuthorization On' | |
# WSGIPassAuthorization will pass the login information sent by the client to the Django view, | |
# as shown below. | |
http_authorization = request.META['HTTP_AUTHORIZATION'] | |
import base64 | |
_user, _password = base64.b64decode(http_authorization[6:]).split(':') | |
user = authenticate(username=_user, password=_password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implementation of JSONEncoder | |
Added pretty printing to html, wherein indents are " " and newlines are "<br>". | |
# added html keyword arg; default is html=False | |
json.dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, html[, separators[, encoding[, default[, **kw]]]]]]]]]]]) | |
Serialize obj to a JSON formatted str. | |
If html is True and indent is not None the encoder indents are printed as " " and newlines are "<br>" | |
""" | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I am using http://isr.nu/ws/WebSocketTest.htm to help debug my websocket connection | |
# and I send websocket requests to ws://127.0.0.1:6767/websockets | |
######## IMPORTANT: | |
######## Add the websocket method to the MessageHandler class | |
## inside brubeck.request_handling- add 'websocket' method: | |
# HTTP_METHODS = ['get', 'post', 'put', 'delete', | |
# 'head', 'options', 'trace', 'connect', 'websocket'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tue, 03 Apr 2012 20:04:50 GMT [WARN] (src/register.c:336: errno: Resource temporarily unavailable) Killed 1 connections according to min_ping: 120, min_write_rate: 300, min_read_rate: 300 | |
Tue, 03 Apr 2012 20:04:50 GMT [WARN] (src/mongrel2.c:205: errno: Resource temporarily unavailable) Timeout task killed 1 tasks, waiting 10 seconds for more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (launch with OSC_send.ck) | |
// the patch | |
// create our OSC receiver | |
OscRecv recv; | |
// use port 6449 | |
6449 => recv.port; | |
// start listening (launch thread) | |
recv.listen(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup_compress = """ | |
for i in xrange(10000): | |
r.hset(str(i), str(i), zlib.compress(10 * "my name is mud", 1))""" | |
setup_normal = """ | |
for i in xrange(10000): | |
r.hset(str(i), str(i), 10 * "my name is mud")""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
import os | |
from brubeck.request_handling import Brubeck, WebMessageHandler | |
from brubeck.connections import Mongrel2Connection | |
from ws4py.framing import Frame, \ | |
OPCODE_CONTINUATION, OPCODE_TEXT, \ | |
OPCODE_BINARY, OPCODE_CLOSE, OPCODE_PING, OPCODE_PONG |
OlderNewer