0

I am implementing ArcGIS Maps SDK for Flutter (version 200.8.0+4672) in my Flutter application. During runtime, I get the following unhandled exception related to HTTP header parsing:

Unhandled Exception: Error on line 1, column 13: expected no more input. E/flutter (21538): ╷ E/flutter (21538): 1 │ max-age=1.00:00:00 E/flutter (21538): │ ^ E/flutter (21538): ╵ E/flutter (21538): #0 StringScanner.error (package:string_scanner/src/string_scanner.dart:263:5) E/flutter (21538): #1 StringScanner._fail (package:string_scanner/src/string_scanner.dart:270:5) E/flutter (21538): #2 StringScanner.expectDone (package:string_scanner/src/string_scanner.dart:219:5) E/flutter (21538): #3 new CacheControl.fromHeader (package:http_cache_core/src/model/cache/cache_control.dart:128:17) E/flutter (21538): #4 CacheStrategyFactory._isCacheable (package:http_cache_core/src/model/cache/cache_strategy.dart:137:40) E/flutter (21538): #5 CacheStrategyFactory.compute (package:http_cache_core/src/model/cache/cache_strategy.dart:82:11) E/flutter (21538): #6 _DioCacheInterceptorUtils._saveResponse (package:dio_cache_interceptor/src/dio_cache_interceptor_cache_utils.dart:82:7) E/flutter (21538): #7 DioCacheInterceptor.onResponse (package:dio_cache_interceptor/src/dio_cache_interceptor.dart:116:11) E/flutter (21538): #8 _ArcGISCacheInterceptor.onResponse (package:arcgis_maps/src/network/arcgis_cache_interceptor.dart:40:11) E/flutter (21538): #9 DioMixin.fetch.responseInterceptorWrapper.. (package:dio/src/dio_mixin.dart:423:17) E/flutter (21538): #10 new Future. (dart:async/future.dart:260:40) E/flutter (21538): #11 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15) E/flutter (21538): #12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:423:19) E/flutter (21538): #13 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:454:5) E/flutter (21538): #14 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)

1 Answer 1

0

How I fixed it:
I intercepted the Cache-Control header in my Flutter Dio client and transformed these invalid max-age values into the correct number of seconds. Key parts of the fix:

Added a regex to recognize durations like max-age=1.00:00:00.
Parsed the days, hours, minutes, and seconds and converted them into seconds.
Replaced the header value with max-age=86400 (for 1 day).
This happens before the cache parsing, preventing the exception.

hashtag#FlutterDev hashtag#GIS hashtag#ArcGIS hashtag#MobileDev hashtag#DartLang hashtag#HttpCaching hashtag#Dio hashtag#FlutterTips hashtag#ArcGISMapsSDK hashtag#ESRI
enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Then why this works for arcgis online services

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.