错误信息:
Caused by: java.lang.IllegalArgumentException: Unexpected char 0x20 at 4 in header name: test
at okhttp3.Headers.checkName(Headers.java:273)
at okhttp3.Headers$Builder.add(Headers.java:323)
at retrofit2.RequestFactory$Builder.parseHeaders(RequestFactory.java:313)
at retrofit2.RequestFactory$Builder.parseMethodAnnotation(RequestFactory.java:248)
at retrofit2.RequestFactory$Builder.build(RequestFactory.java:181)
at retrofit2.RequestFactory.parseAnnotations(RequestFactory.java:67)
at retrofit2.ServiceMethod.parseAnnotations(ServiceMethod.java:26)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:202)
at retrofit2.Retrofit$1.invoke(Retrofit.java:160)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy4.obtainScannedImageFile(Unknown Source)
at com.cirros.ricoh.scan.model.ScanModel.obtainScannedImageFile(ScanModel.java:53)
at com.cirros.ricoh.scan.presenter.ScanPresenter.obtainScannedImageFile(ScanPresenter.java:65)
at com.cirros.ricoh.scan.activity.ScanActivity.lambda$initView$0$ScanActivity(ScanActivity.java:354)
at com.cirros.ricoh.scan.activity.-$$Lambda$ScanActivity$6L2Sl-L4ZoBn_4k8KxAV_MBTgSw.accept(lambda)
at io.reactivex.internal.subscribers.LambdaSubscriber.onNext(LambdaSubscriber.java:65)
... 10 more
错误是出现特殊字符空格,如下:
@Headers("test : gw.address:54080")
@GET("/test")
Call<Object> test();
其实错误消息也提示是第四个字符错误,从0到4刚好是空格。
解决
只需要把那个空格删除掉就行。
其实是okhttp头部header做了拦截,有一些特殊字符和格式过不去。
我这里就是格式错误导致的,只需要把test后面的空格删除掉就行,让:连接test就行。
@Headers("test: gw.address:54080")
@GET("/test")
Call<Object> test();
网友评论