Skip to content

head file error, when server return '' content #23

@dawn110110

Description

@dawn110110

ut 里:
image

requests/models.py 901 行,里我加了些输出:

image

从第一个截图可以看出,head 请求返回的是 空串 ,然后当 json 解析报错了?

Traceback (most recent call last):
........
  File "/opt/python_root/ins/lib/python3.9/site-packages/ufile/filemanager.py", line 421, in head_file
    return _head_file(url, header)
  File "/opt/python_root/ins/lib/python3.9/site-packages/ufile/httprequest.py", line 118, in _head_file
    return __return_wraper(response)
  File "/opt/python_root/ins/lib/python3.9/site-packages/ufile/httprequest.py", line 20, in __return_wraper
    ret = {} if content_consumed else response.json() if isinstance(content_type, str) and content_type.startswith('application/json') else {}
  File "/opt/python_root/ins/lib/python3.9/site-packages/requests/models.py", line 903, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/python_root/ins/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/opt/python_root/ins/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/python_root/ins/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

测试代码截图:

self.s3 是我简单封装过的 ufile sdk.

image

文件我是实际传上去了的.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions