88from functools import partial
99from json import JSONDecodeError
1010from os import getenv
11- from typing import Any , Callable , List , Optional
11+ from typing import Any , Callable , List , Optional , Dict , Union
1212
1313from AnyQt .QtCore import QSettings
1414from httpx import AsyncClient , NetworkError , ReadTimeout , Response
@@ -306,7 +306,7 @@ async def _send_to_server(
306306 queue .task_done ()
307307
308308 async def _send_request (
309- self , client : AsyncClient , data : bytes , url : str
309+ self , client : AsyncClient , data : Union [ bytes , Dict ] , url : str
310310 ) -> Optional [List [float ]]:
311311 """
312312 This function sends a single request to the server.
@@ -331,7 +331,9 @@ async def _send_request(
331331 "Content-Length" : str (len (data )),
332332 }
333333 try :
334- response = await client .post (url , headers = headers , data = data )
334+ # bytes are sent as content parameter and dictionary as data
335+ kwargs = dict (content = data ) if isinstance (data , bytes ) else dict (data = data )
336+ response = await client .post (url , headers = headers , ** kwargs )
335337 except ReadTimeout as ex :
336338 log .debug ("Read timeout" , exc_info = True )
337339 # it happens when server do not respond in time defined by timeout
0 commit comments