我得到一个
HttpException:无法解析标头值
当使用M2 发布dart http和oauth2库调用 http.Client.get(Uri) 方法时。我正在尝试使用 API 来执行File: get。我成功地将我的授权请求重定向到一个简单的基于控制台的 http 服务器以获取令牌。然后以下代码会导致异常:
oauth.Credentials credentials = new oauth.Credentials(code);
http.Client client = new oauth.Client(CLIENT_ID, CLIENT_SECRET, credentials);
Uri uri = new Uri("https://www.googleapis.com/drive/v2/files/$fileID");
Future<http.Response> result = client.get(uri);
以下是完整的堆栈跟踪:
HttpException: Failed to parse header value
Unhandled exception:
FutureUnhandledException: exception while executing Future
HttpException: Failed to parse header value
original stack trace:
null
#0 _FutureImpl._complete (bootstrap:844:11)
#1 _FutureImpl._complete (bootstrap:848:5)
#2 _FutureImpl._setException (bootstrap:873:14)
#3 _CompleterImpl.completeException (bootstrap:952:30)
#4 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#5 _FutureImpl._complete (bootstrap:832:22)
#6 _FutureImpl._complete (bootstrap:848:5)
#7 _FutureImpl._setException (bootstrap:873:14)
#8 _CompleterImpl.completeException (bootstrap:952:30)
#9 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#10 _FutureImpl._complete (bootstrap:832:22)
#11 _FutureImpl._complete (bootstrap:848:5)
#12 _FutureImpl._setException (bootstrap:873:14)
#13 _CompleterImpl.completeException (bootstrap:952:30)
#14 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#15 _FutureImpl._complete (bootstrap:832:22)
#16 _FutureImpl._complete (bootstrap:848:5)
#17 _FutureImpl._setException (bootstrap:873:14)
#18 _CompleterImpl.completeException (bootstrap:952:30)
#19 _FutureImpl._forwardException.<anonymous closure> (bootstrap:936:34)
#20 _FutureImpl._complete (bootstrap:832:22)
#21 _FutureImpl._complete (bootstrap:848:5)
#22 _FutureImpl._setException (bootstrap:873:14)
#23 _CompleterImpl.completeException (bootstrap:952:30)
#24 IOClient.send.<anonymous closure>.<anonymous closure> (package:http/src/io_client.dart:38:36)
#25 _FutureImpl._complete (bootstrap:840:19)
#26 _FutureImpl._complete (bootstrap:848:5)
#27 _FutureImpl._setValue (bootstrap:862:14)
#28 _CompleterImpl.complete (bootstrap:949:26)
#29 async.<anonymous closure> (package:http/src/utils.dart:173:41)
#30 _Timer._createTimerHandler._handleTimeout (dart:io:7035:28)
#31 _Timer._createTimerHandler._handleTimeout (dart:io:7043:7)
#32 _Timer._createTimerHandler.<anonymous closure> (dart:io:7051:23)
#33 _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)