gpt4 book ai didi

android - 值错误 : unconverted data remains: +00:00

转载 作者:太空宇宙 更新时间:2023-11-04 05:31:12 26 4
gpt4 key购买 nike

我正在尝试使用 eve 构建 API。当我使用“POSTMAN”测试我的 api 时,一切都很好,但是当我使用 android 应用程序时,我在 PyCharm 有这个日志。我使用 Volley 作为 HTTP 库。谢谢你的帮助

127.0.0.1 - - [08/May/2016 10:37:29] "GET /accounts HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/eve/flaskapp.py", line 946, in __call__
return super(Eve, self).__call__(environ, start_response)
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3.5/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/python3.5/site-packages/eve/endpoints.py", line 54, in collections_endpoint
response = get(resource, lookup)
File "/usr/lib/python3.5/site-packages/eve/methods/common.py", line 242, in rate_limited
return f(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/eve/auth.py", line 79, in decorated
return f(*args, **kwargs)
File "/usr/lib/python3.5/site-packages/eve/methods/common.py", line 944, in decorated
r = f(resource, **combined_args)
File "/usr/lib/python3.5/site-packages/eve/methods/get.py", line 92, in get
req = parse_request(resource)
File "/usr/lib/python3.5/site-packages/eve/utils.py", line 155, in parse_request
r.if_modified_since = weak_date(headers.get('If-Modified-Since'))
File "/usr/lib/python3.5/site-packages/eve/utils.py", line 174, in weak_date
timedelta(seconds=1) if date else None
File "/usr/lib/python3.5/_strptime.py", line 500, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "/usr/lib/python3.5/_strptime.py", line 340, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: +00:00

最佳答案

客户端似乎在 If-Modified-Since header 中发送了无效日期,即日期不符合 RFC 1123 中描述的格式.这种格式的一个例子是

Sun, 08 May 2016 10:00:00 GMT

Possibly a date like this is being sent by the client, i.e. Volley:

Sun, 08 May 2016 10:00:00 GMT+00:00

eve can't handle that because it parses times using this format string:

RFC1123_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'

尚不清楚无效时区值的来源。查看 volley 代码,它将接受并传播时区,例如 GMT+00:00,但不会生成它们。同样,eve 代码不会生成它们。

可能您的 API 以某种方式返回带有 +00:00 的日期,然后 volley 在对您的 API 的下一个请求中回显该值?或者,它可能源自 Android 应用程序。

我会专注于确定无效日期的来源。尝试在 eve/flask 中转储请求 header ,并在可能的情况下在 volley 中执行相同的操作。

关于android - 值错误 : unconverted data remains: +00:00,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37098453/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com