Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.helidon.webclient.http1;
import java.io.ByteArrayOutputStream;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import io.helidon.common.GenericType;
import io.helidon.common.buffers.BufferData;
import io.helidon.http.Header;
import io.helidon.http.HeaderNames;
import io.helidon.http.Method;
import io.helidon.http.Status;
import io.helidon.http.media.EntityWriter;
import io.helidon.http.media.InstanceWriter;
import io.helidon.http.media.MediaContext;
import io.helidon.webclient.api.ClientRequestBase;
import io.helidon.webclient.api.ClientUri;
import io.helidon.webclient.api.Proxy.ProxyType;
import io.helidon.webclient.api.WebClientServiceRequest;
import io.helidon.webclient.api.WebClientServiceResponse;
class Http1ClientRequestImpl extends ClientRequestBase implements Http1ClientRequest {
private static final System.Logger LOGGER = System.getLogger(Http1ClientRequestImpl.class.getName());
private final Http1ClientImpl http1Client;
Http1ClientRequestImpl(Http1ClientImpl http1Client,
Method method,
ClientUri clientUri,
Map properties) {
super(http1Client.clientConfig(),
http1Client.webClient().cookieManager(),
Http1Client.PROTOCOL_ID,
method, clientUri,
properties);
this.http1Client = http1Client;
}
//Copy constructor for redirection purposes
Http1ClientRequestImpl(Http1ClientRequestImpl request,
Method method,
ClientUri clientUri,
Map properties) {
this(request.http1Client,
method,
clientUri,
properties);
followRedirects(request.followRedirects());
maxRedirects(request.maxRedirects());
tls(request.tls());
}
@Override
public Http1ClientResponse doSubmit(Object entity) {
byte[] entityBytes;
if (entity == BufferData.EMPTY_BYTES) {
entityBytes = BufferData.EMPTY_BYTES;
} else if (entity instanceof byte[] buffer) {
entityBytes = buffer;
} else {
// must apply media writer, and if the writer has unknown length, or longer than we can buffer, stream it
GenericType