okhttpclient версии 4-12.0 Отправляет запрос многообработки с использованием конфигурации по умолчанию; Север отвечает 100-конфликтом. После получения пары из 100-концентрации okhttpclient выходит из строя с помощью нелегальной статей состояния 3 .
Другое httpclient (например, curl 7.81.0, Apache httpclient 4.5.13, Vertx и т. Д.) Использование конфигурации по умолчанию, как ожидалось, с тем же сервером. Является ли 100-конфликт не поддерживается Okhttpclient или есть что-то еще, чтобы заставить работу OkhttpClient с ответом 100-континового?Exception in thread "main" java.lang.IllegalStateException: state: 3
at okhttp3.internal.http1.Http1ExchangeCodec.newFixedLengthSource(Http1ExchangeCodec.kt:227)
at okhttp3.internal.http1.Http1ExchangeCodec.openResponseBodySource(Http1ExchangeCodec.kt:132)
at okhttp3.internal.connection.Exchange.openResponseBody(Exchange.kt:129)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:130)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
< /code>
RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), file);
MultipartBody multipartBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("somefile",file.getName(),fileBody)
.build();
Request request = new Request.Builder()
// .header("Expect","100-continue") //makes no difference ...
.url(url)
.post(multipartBody)
.build();
try (Response response = client.newCall(request).execute()){
log.info("Response Code {}",response.code());
} catch (IOException e) {
...
}
< /code>
Issue seems to be similar to https://github.com/square/okhttp/issues/3628 and is present in version 3.11; Any suggestion to get 100-continue working ?
==================================================================
On further investigation
100-continue response from the server
Response{protocol=http/1.1, code=100, message=Continue, url=http://localhost:8443/someendpoint}
< /code>
CallServerInterceptor:
response = if (forWebSocket && code == 101) {
// Connection is upgrading, but we need to ensure interceptors see a non-null response body.
response.newBuilder()
.body(EMPTY_RESPONSE)
.build()
} else {
response.newBuilder()
.body(exchange.openResponseBody(response))
.build()
}
< /code>
I think the issue is caused by setting the state to
STATE_READ_RESPONSE_HEADERS on the first 100-Continue response and expect the state to be in STATE_OPEN_RESPONSE_BODY when subsequent 100-Continue responses are received. If not it will throw illegalStateException.
It appears OkHttpClient is not able to ignore subsequent 100-Continue responses from the server. Is this the case?
Подробнее здесь: https://stackoverflow.com/questions/795 ... 0-continue
Okhttpclient выбрасывает нелегальное статей, когда сервер отвечает 100-конфликтом ⇐ Android
Форум для тех, кто программирует под Android
1744367867
Anonymous
okhttpclient версии 4-12.0 Отправляет запрос многообработки с использованием конфигурации по умолчанию; Север отвечает 100-конфликтом. После получения пары из 100-концентрации okhttpclient выходит из строя с помощью нелегальной статей [b] состояния 3 [/b].
Другое httpclient (например, curl 7.81.0, Apache httpclient 4.5.13, Vertx и т. Д.) Использование конфигурации по умолчанию, как ожидалось, с тем же сервером. Является ли 100-конфликт не поддерживается Okhttpclient или есть что-то еще, чтобы заставить работу OkhttpClient с ответом 100-континового?Exception in thread "main" java.lang.IllegalStateException: state: 3
at okhttp3.internal.http1.Http1ExchangeCodec.newFixedLengthSource(Http1ExchangeCodec.kt:227)
at okhttp3.internal.http1.Http1ExchangeCodec.openResponseBodySource(Http1ExchangeCodec.kt:132)
at okhttp3.internal.connection.Exchange.openResponseBody(Exchange.kt:129)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:130)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
< /code>
RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), file);
MultipartBody multipartBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("somefile",file.getName(),fileBody)
.build();
Request request = new Request.Builder()
// .header("Expect","100-continue") //makes no difference ...
.url(url)
.post(multipartBody)
.build();
try (Response response = client.newCall(request).execute()){
log.info("Response Code {}",response.code());
} catch (IOException e) {
...
}
< /code>
Issue seems to be similar to https://github.com/square/okhttp/issues/3628 and is present in version 3.11; Any suggestion to get 100-continue working ?
==================================================================
On further investigation
100-continue response from the server
Response{protocol=http/1.1, code=100, message=Continue, url=http://localhost:8443/someendpoint}
< /code>
CallServerInterceptor:
response = if (forWebSocket && code == 101) {
// Connection is upgrading, but we need to ensure interceptors see a non-null response body.
response.newBuilder()
.body(EMPTY_RESPONSE)
.build()
} else {
response.newBuilder()
.body(exchange.openResponseBody(response))
.build()
}
< /code>
I think the issue is caused by setting the state to
STATE_READ_RESPONSE_HEADERS on the first 100-Continue response and expect the state to be in STATE_OPEN_RESPONSE_BODY when subsequent 100-Continue responses are received. If not it will throw illegalStateException.
It appears OkHttpClient is not able to ignore subsequent 100-Continue responses from the server. Is this the case?
Подробнее здесь: [url]https://stackoverflow.com/questions/79567656/okhttpclient-throws-illegalstateexception-when-server-responds-with-100-continue[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия