Exemplo n.º 1
0
def delete(arguments, resource):
    sock = get_socket(arguments)

    request = HTTPRequest(verb="DELETE", resource=resource)

    request.writeTo(sock)
    response = HTTPResponse.readFrom(sock)

    return response.code == 200
Exemplo n.º 2
0
def delete(arguments, resource):
    sock = get_socket(arguments)
    
    request = HTTPRequest(verb="DELETE", resource=resource)
    
    request.writeTo(sock)
    response = HTTPResponse.readFrom(sock)
    
    return response.code == 200
Exemplo n.º 3
0
def upload(arguments, resource, data, magic=None, mimetype=None, headers=None):
    sock = get_socket(arguments)
    
    request = HTTPRequest(verb="POST", resource=resource, headers=headers, body=data)
    if arguments.credentials != None:
        request.headers["Authorization"] = "Basic %s" % b64encode(":".join(arguments.credentials))
    request.headers["Content-Length"] = len(data)
    if mimetype != None:
        request.headers["Content-Type"] = mimetype
    if magic != None:
        request.headers["X-Drozer-Magic"] = magic
        
    request.writeTo(sock)
    response = HTTPResponse.readFrom(sock)

    return response.status == 201
Exemplo n.º 4
0
def upload(arguments, resource, data, magic=None, mimetype=None, headers=None):
    sock = get_socket(arguments)

    request = HTTPRequest(verb="POST",
                          resource=resource,
                          headers=headers,
                          body=data)
    if arguments.credentials != None:
        request.headers["Authorization"] = "Basic %s" % b64encode(":".join(
            arguments.credentials))
    request.headers["Content-Length"] = len(data)
    if mimetype != None:
        request.headers["Content-Type"] = mimetype
    if magic != None:
        request.headers["X-Drozer-Magic"] = magic

    request.writeTo(sock)
    response = HTTPResponse.readFrom(sock)

    return response.status == 201