Skip to content

Commit b35f4f4

Browse files
authored
Merge commit from fork
Signed-off-by: Frost Ming <[email protected]>
1 parent 93717e2 commit b35f4f4

File tree

1 file changed

+8
-1
lines changed
  • src/_bentoml_impl/server

1 file changed

+8
-1
lines changed

src/_bentoml_impl/server/app.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ async def create_instance(self, app: Starlette) -> None:
296296
deployment_url, service=self.service, media_type="application/json"
297297
)
298298
else:
299-
proxy = RemoteProxy("http://localhost:3000", service=self.service, app=app)
299+
proxy = RemoteProxy("http://localhost:3000", service=self.service, app=app, media_type="application/json")
300300
self._service_instance.__self_proxy__ = proxy # type: ignore[attr-defined]
301301
self._service_instance.to_async = proxy.to_async # type: ignore[attr-defined]
302302
self._service_instance.to_sync = proxy.to_sync # type: ignore[attr-defined]
@@ -641,12 +641,19 @@ async def api_endpoint(self, name: str, request: Request) -> Response:
641641
from _bentoml_sdk.io_models import IORootModel
642642
from bentoml._internal.utils import get_original_func
643643
from bentoml._internal.utils.http import set_cookies
644+
from http import HTTPStatus
644645

645646
from ..serde import ALL_SERDE
646647

647648
media_type = request.headers.get("Content-Type", "application/json")
648649
media_type = media_type.split(";")[0].strip()
649650

651+
if self.is_main and media_type == "application/vnd.bentoml+pickle":
652+
raise BentoMLException(
653+
"application/vnd.bentoml+pickle is not allowed in main server",
654+
error_code=HTTPStatus.UNSUPPORTED_MEDIA_TYPE,
655+
)
656+
650657
method = self.service.apis[name]
651658
func = getattr(self._service_instance, name).local
652659
ctx = self.service.context

0 commit comments

Comments
 (0)