예제 #1
0
파일: client.py 프로젝트: jahosp/rsteg-tcp
def post(host, path, data):
    """Sends POST request using HttpClient and the data from GUI form.
    :param host: host ip addr
    :param path: resource endpoint path
    :param data: data to be sent as body of the POST request
    :return: HTTP response body
    """
    cover = open(data, 'rb').read()
    print('Sending POST ' + path + ' HTTP/1.1 request to ' + host)
    window.refresh()
    print('RSTEG not activated.')
    window.refresh()
    c = HttpClient(49512)
    req = c.create_post_request(host, path, cover, 'image/jpg')
    res = c.request(bytes(req), host)
    print('Response: ' + res.split(b'\r\n')[0].decode())
    window.refresh()

    return res
예제 #2
0
파일: client.py 프로젝트: jahosp/rsteg-tcp
def rpost(host, path, data, secret_data, rprob):
    """Sends rPOST request using HttpClient and the data from GUI form.
    :param host: host ip addr
    :param path: resource endpoint path
    :param data: data to be sent as body of the POST request
    :param secret_data: secret to be sent using the RSTEG mechanism
    :param rprob: retransmission probability
    :return: HTTP response body
    """
    cover = open(data, 'rb').read()
    secret = open(secret_data, 'rb').read()
    print('Sending POST ' + path + ' HTTP/1.1 request to ' + host)
    print('Using RSTEG to send secret.')
    window.refresh()
    c = HttpClient(float(rprob), 49512)
    req = c.create_post_request(host, path, cover, 'image/jpg')
    res = c.rsteg_request(bytes(req), secret, host)
    print('Response: ' + res.split(b'\r\n')[0].decode())

    return res