Tweak headers to accept default when none are specified

This commit is contained in:
doctorpangloss 2024-04-01 20:34:55 -07:00
parent 5208618681
commit abb952ad77

View File

@ -553,6 +553,7 @@ class PromptServer(ExecutorToClientProgress):
async def post_prompt(request: web.Request) -> web.Response | web.FileResponse: async def post_prompt(request: web.Request) -> web.Response | web.FileResponse:
# check if the queue is too long # check if the queue is too long
accept = request.headers.get("accept", "application/json") accept = request.headers.get("accept", "application/json")
content_type = request.headers.get("content-type", "application/json")
queue_size = self.prompt_queue.size() queue_size = self.prompt_queue.size()
queue_too_busy_size = PromptServer.get_too_busy_queue_size() queue_too_busy_size = PromptServer.get_too_busy_queue_size()
if queue_size > queue_too_busy_size: if queue_size > queue_too_busy_size:
@ -560,9 +561,9 @@ class PromptServer(ExecutorToClientProgress):
reason=f"the queue has {queue_size} elements and {queue_too_busy_size} is the limit for this worker") reason=f"the queue has {queue_size} elements and {queue_too_busy_size} is the limit for this worker")
# read the request # read the request
prompt_dict: dict = {} prompt_dict: dict = {}
if request.headers[aiohttp.hdrs.CONTENT_TYPE] == 'application/json': if content_type == 'application/json':
prompt_dict = await request.json() prompt_dict = await request.json()
elif request.headers[aiohttp.hdrs.CONTENT_TYPE] == 'multipart/form-data': elif content_type == 'multipart/form-data':
try: try:
reader = await request.multipart() reader = await request.multipart()
async for part in reader: async for part in reader: