Beispiel #1
0
def test_post_byte_iterator(server):
    def data():
        yield b"Hello"
        yield b", "
        yield b"world!"

    response = http3.post("http://127.0.0.1:8000/", data=data())
    assert response.status_code == 200
    assert response.reason_phrase == "OK"
# Using http3

import http3

r = http3.get('https://news.ycombinator.com/')

print(r.url)
print(r)
print(r.status_code)
print(r.protocol)
print(r.headers['content-type'])
print(r.text)

params = {'key1': 'value1', 'key2': 'value2'}
s = http3.get('https://httpbin.org/', params=params)
s = http3.post('https://httpbin.org/post', data={'key': 'value'})

print(s.url)
print(s)
print(s.status_code)
print(s.protocol)
print(s.headers['content-type'])
print(s.text)

t = http3.get('http://github.com/', allow_redirects=False)

print(t.url)
print(t)
print(t.status_code)
print(t.protocol)
Beispiel #3
0
import http3
import os
from pprint import pprint
import sys

# create contact via send in blue http interface
# https://api.sendinblue.com/v3/contacts
# body params
# email
email = sys.argv[1]

try:
    url = 'https://api.sendinblue.com/v3/contacts'
    sibkey = os.environ['SEND_IN_BLUE_KEY']
    headers = {'api-key': sibkey}
    data = {'email': email}
    r = http3.post(url, headers=headers, json=data)
    pprint(r)
    pprint(r.json())

except Exception as e:
    print("Exception when calling ContactsApi->create_contact: %s\n" % e)
Beispiel #4
0
def test_post(server):
    response = http3.post("http://127.0.0.1:8000/", data=b"Hello, world!")
    assert response.status_code == 200
    assert response.reason_phrase == "OK"