Skip to content

Commit bcb0869

Browse files
authored
Merge pull request #81 from serv-c/drgroot-patch-1
fix(http): accept multi contenttype
2 parents 0431269 + fcc021c commit bcb0869

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

servc/svc/com/http/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import json
12
import os
23
from multiprocessing import Process
34
from typing import Dict, List, Tuple, TypedDict
45

56
from flask import Flask, jsonify, request # type: ignore
6-
77
from servc.svc import ComponentType, Middleware
88
from servc.svc.client.send import sendMessage
99
from servc.svc.com.bus import BusComponent
@@ -119,11 +119,14 @@ def _getResponse(self, id: str):
119119
def _postMessage(self, extra_params: Dict | None = None):
120120
if not extra_params:
121121
extra_params = {}
122-
content_type = request.headers.get("Content-Type", None)
122+
content_type = request.headers.get("Content-Type", "")
123123
if request.method == "GET":
124124
return self._getInformation()
125-
if content_type == "application/json":
126-
body = request.json
125+
if content_type == "application/json" or "multipart/form-data" in content_type:
126+
if "multipart/form-data" in content_type:
127+
body = json.loads(request.form["json"])
128+
else:
129+
body = request.json
127130
if not body:
128131
return "bad request", StatusCode.INVALID_INPUTS.value
129132

0 commit comments

Comments
 (0)