Repository: kserve/kserve

Issue:
Download request for Kserve custom resource model that does not recognize HTTP
/kind bug

**What steps did you take and what happened:**
[A clear and concise description of what the bug is.]
After I created a custom resource through the InferenceService, I provided a correct model link that can be downloaded through HTTP. The Pod created by the custom resource will prompt the following error: "RuntimeError: URI: http://bw-model-svc.bluewhale-platform:8001/modelservice/model/download?path=/bluewhale/model/74/00000123.zip Did not respond with 'Content Type': 'application/octet stream'

**What did you expect to happen:**
I hope this link can be correctly recognized by Kserve

**What's the InferenceService yaml:**
[To help us debug please run `kubectl get isvc $name -n $namespace -oyaml` and paste the output]
```
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  annotations:
    serving.kserve.io/deploymentMode: RawDeployment
  finalizers:
    - inferenceservice.finalizers
  name: bw-model-api-4051
  namespace: bluewhale-platform
spec:
  predictor:
    model:
      modelFormat:
        name: Tensorflow
      name: ''
      resources: {}
      storageUri: >-
        http://bw-model-svc.bluewhale-platform:8001/modelservice/model/download?path=/bluewhale/model/74/00000123.zip
```
**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]


**Environment:**


- KServe Version: v0.10.0


Discussion:

Resolving patch:
diff --git a/python/kserve/kserve/storage/storage.py b/python/kserve/kserve/storage/storage.py
--- a/python/kserve/kserve/storage/storage.py
+++ b/python/kserve/kserve/storage/storage.py
@@ -525,7 +525,11 @@ def _download_local(uri, out_dir=None):
     def _download_from_uri(uri, out_dir=None):
         url = urlparse(uri)
         filename = os.path.basename(url.path)
-        mimetype, encoding = mimetypes.guess_type(url.path)
+        # Determine if the symbol '?' exists in the path
+        if mimetypes.guess_type(url.path)[0] is None and url.query != '':
+            mimetype, encoding = mimetypes.guess_type(url.query)
+        else:
+            mimetype, encoding = mimetypes.guess_type(url.path)
         local_path = os.path.join(out_dir, filename)
 
         if filename == '':


Test patch:
diff --git a/python/kserve/kserve/storage/test/test_storage.py b/python/kserve/kserve/storage/test/test_storage.py
--- a/python/kserve/kserve/storage/test/test_storage.py
+++ b/python/kserve/kserve/storage/test/test_storage.py
@@ -118,6 +118,11 @@ def test_https_uri_path(_):
     ('https://theabyss.net/model.joblib', MockHttpResponse(404), RuntimeError),
     ('https://some.site.com/test.model', MockHttpResponse(status_code=200, content_type='text/html'), RuntimeError),
     ('https://foo.bar/test/', MockHttpResponse(200), ValueError),
+    ('https://foo.bar/download?path=/20210530/model.zip', MockHttpResponse(200, FILE_ZIP_RAW, 'application/zip'), None),
+    ('https://foo.bar/download?path=/20210530/model.zip', MockHttpResponse(200, FILE_ZIP_RAW, 'application/x-zip'
+                                                                                              '-compressed'), None),
+    ('https://foo.bar/download?path=/20210530/model.zip', MockHttpResponse(200, FILE_ZIP_RAW, 'application/zip'
+                                                                                              '-compressed'), None),
 ]