def proxy(request):
    if 'url' not in request.GET:
        return HttpResponse(
                "The proxy service requires a URL-encoded URL as a parameter.",
                status=400,
                content_type="text/plain"
                )

    url = urlsplit(request.GET['url'])

    # Don't allow localhost connections unless in DEBUG mode
    if not settings.DEBUG and re.search('localhost|127.0.0.1', url.hostname):
        return HttpResponse(status=403)

    locator = url.path
    if url.query != "":
        locator += '?' + url.query
    if url.fragment != "":
        locator += '#' + url.fragment

    # Strip all headers and cookie info
    headers = {}


    conn = HTTPConnection(url.hostname, url.port) if url.scheme == "http" else HTTPSConnection(url.hostname, url.port)
    conn.request(request.method, locator, request.raw_post_data, headers)
    result = conn.getresponse()

    response = HttpResponse(
            valid_response(result.read()),
            status=result.status,
            content_type=result.getheader("Content-Type", "text/plain")
            )

    return response