Beispiel #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
Beispiel #2
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-andsploit-Magic"] = magic
        
    request.writeTo(sock)
    response = HTTPResponse.readFrom(sock)

    return response.status == 201
#201(已创建)请求成功并且服务器创建了新的资源。