Fixing empty header + ensuring security (#313)

* Fixing empty header + ensuring security
This commit is contained in:
Parth Sareen
2024-11-07 13:12:22 -08:00
committed by Michael Yang
parent f25834217b
commit 72052188c3
2 changed files with 25 additions and 4 deletions
+16
View File
@@ -968,3 +968,19 @@ async def test_async_client_copy(httpserver: HTTPServer):
client = AsyncClient(httpserver.url_for('/api/copy'))
response = await client.copy('dum', 'dummer')
assert response['status'] == 'success'
def test_headers():
client = Client()
assert client._client.headers['content-type'] == 'application/json'
assert client._client.headers['accept'] == 'application/json'
assert client._client.headers['user-agent'].startswith('ollama-python/')
client = Client(
headers={
'X-Custom': 'value',
'Content-Type': 'text/plain',
}
)
assert client._client.headers['x-custom'] == 'value'
assert client._client.headers['content-type'] == 'application/json'