@@ -296,7 +296,7 @@ async def create_instance(self, app: Starlette) -> None:
296
296
deployment_url , service = self .service , media_type = "application/json"
297
297
)
298
298
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" )
300
300
self ._service_instance .__self_proxy__ = proxy # type: ignore[attr-defined]
301
301
self ._service_instance .to_async = proxy .to_async # type: ignore[attr-defined]
302
302
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:
641
641
from _bentoml_sdk .io_models import IORootModel
642
642
from bentoml ._internal .utils import get_original_func
643
643
from bentoml ._internal .utils .http import set_cookies
644
+ from http import HTTPStatus
644
645
645
646
from ..serde import ALL_SERDE
646
647
647
648
media_type = request .headers .get ("Content-Type" , "application/json" )
648
649
media_type = media_type .split (";" )[0 ].strip ()
649
650
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
+
650
657
method = self .service .apis [name ]
651
658
func = getattr (self ._service_instance , name ).local
652
659
ctx = self .service .context
0 commit comments