silk-deployment / silk /

#!/usr/bin/env python

import sys
import socket

REQUEST_TEMPLATE = ('%(method)s %(path)s HTTP/1.1\r\n'
                    'Host: %(host)s\r\n\r\n')


def sockhttp(sockpath, method, path, host):
    """Make an HTTP request over a unix socket."""
    req = REQUEST_TEMPLATE % locals()
    s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    out = ''
    while 1:
        data = s.recv(1024)
        out += data
        if not data: break
    return out

def usage():
    """Print usage information for this program"""
    print ("This program allows you to make http requests to unix sockets. "
           "python %s /path/to/socket METHOD request_path host_name\n" %

    print "Supported methods are: %s" % ", ".join(SUPPORTED_METHODS)

if __name__ == '__main__':
        _, sockpath, method, path, host = sys.argv
    except ValueError:
    print sockhttp(sockpath, method, path, host)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.