aptly icon indicating copy to clipboard operation
aptly copied to clipboard

API: HTTP 400 on mirror update when Content-Type application/json is set

Open sinuscosinustan opened this issue 3 years ago • 1 comments

Detailed Description

When the Content-Type header is set to application/json on a mirror update via API (no matter if async or not), the API throws HTTP 400 and {"error":"EOF"}.

python3 test.py update --async ceph-quincy-focal
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:9091
send: b'PUT /api/mirrors/ceph-quincy-focal?_async=true HTTP/1.1\r\nHost: localhost:9091\r\nUser-Agent: python-requests/2.25.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/json\r\nContent-Length: 0\r\n\r\n'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Thu, 06 Oct 2022 15:12:13 GMT
header: Content-Length: 15
header: Content-Type: text/plain; charset=utf-8
DEBUG:urllib3.connectionpool:http://localhost:9091 "PUT /api/mirrors/ceph-quincy-focal?_async=true HTTP/1.1" 400 15
{'error': 'EOF'}

Context

I tried to update a mirror via API with a generic method which sets the Content-Type to application/json by default.

Your Environment

$ aptly version
aptly version: '1.5.0'

sinuscosinustan avatar Oct 06 '22 15:10 sinuscosinustan

Probably it is a silly question... But do we actually need to provide header Content-Type since on mirror update we are not uploading any files? I can confirm that without setting Content-Type mirrors can be successfully updated.

xaoc7 avatar Nov 17 '22 05:11 xaoc7