src/main/java/com/qingstor/sdk/request/RequestHandler.java
private void checkDownloadRequest() {
        if (outputClass == null) return;
        boolean isDownloadRequest = false;
        Field[] declaredField = outputClass.getDeclaredFields();
        for (Field field : declaredField) {
            String methodName = "get" + QSParamInvokeUtil.capitalize(field.getName());
            Method[] methods = outputClass.getDeclaredMethods();
            for (Method m : methods) {
                if (m.getName().equalsIgnoreCase(methodName)) {
                    ParamAnnotation annotation = m.getAnnotation(ParamAnnotation.class);
                    if (annotation == null) continue;
                    if ("BodyInputStream".equals(annotation.paramName())) {
                        isDownloadRequest = true;
                        break;
                    }
                }
            }
        }
        if (isDownloadRequest) {
            getBuilder().setHeader("Accept-Encoding", "identity");
        }
    }
private void checkDownloadRequest() {
        if (outputClass == null) return;
        boolean isDownloadRequest = false;
        Field[] declaredField = outputClass.getDeclaredFields();
        for (Field field : declaredField) {
            String methodName = "get" + QSParamInvokeUtil.capitalize(field.getName());
            Method[] methods = outputClass.getDeclaredMethods();
            for (Method m : methods) {
                if (m.getName().equalsIgnoreCase(methodName)) {
                    ParamAnnotation annotation = m.getAnnotation(ParamAnnotation.class);
                    if (annotation == null) continue;
                    if ("BodyInputStream".equals(annotation.paramName())) {
                        isDownloadRequest = true;
                        break;
                    }
                }
            }
        }
        if (isDownloadRequest) {
            getBuilder().setHeader("Accept-Encoding", "identity");
        }
    }
private void checkDownloadRequest ( ) { if ( outputClass == null ) return ; boolean isDownloadRequest = false ; Field [ ] declaredField = outputClass . getDeclaredFields ( ) ; for ( Field field : declaredField ) { String methodName = "get" + QSParamInvokeUtil . capitalize ( field . getName ( ) ) ; Method [ ] methods = outputClass . getDeclaredMethods ( ) ; for ( Method m : methods ) { if ( m . getName ( ) . equalsIgnoreCase ( methodName ) ) { ParamAnnotation annotation = m . getAnnotation ( ParamAnnotation . class ) ; if ( annotation == null ) continue ; if ( "BodyInputStream" . equals ( annotation . paramName ( ) ) ) { isDownloadRequest = true ; break ; } } } } if ( isDownloadRequest ) { getBuilder ( ) . setHeader ( "Accept-Encoding" , "identity" ) ; } }
<p> OkHttp will use "Accept-Encoding: gzip" as default header,
which may not get Content-Length form server when download. </p>
<p > OkHttp will use Accept - Encoding : gzip as default header which may not get Content - Length form server when download . < / p >