Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sdk/core/azure-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@
--add-opens com.azure.core/com.azure.core.implementation.models.jsonflatten=com.fasterxml.jackson.databind
--add-opens com.azure.core/com.azure.core.implementation.models.jsonflatten=ALL-UNNAMED
--add-opens com.azure.core/com.azure.core.implementation.serializer=ALL-UNNAMED
--add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
--add-opens com.azure.core/com.azure.core.models=ALL-UNNAMED
--add-opens com.azure.core/com.azure.core.util=ALL-UNNAMED
--add-opens com.azure.core/com.azure.core.util.jsonpatch=ALL-UNNAMED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

package com.azure.core.http;

import com.azure.core.implementation.util.FluxByteBufferContent;
import com.azure.core.util.RequestContent;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Flux;

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

/**
* The outgoing Http request. It provides ways to construct {@link HttpRequest} with {@link HttpMethod}, {@link URL},
Expand All @@ -22,7 +21,7 @@ public class HttpRequest {
private HttpMethod httpMethod;
private URL url;
private HttpHeaders headers;
private RequestContent requestContent;
private Flux<ByteBuffer> body;

/**
* Create a new HttpRequest instance.
Expand All @@ -31,7 +30,7 @@ public class HttpRequest {
* @param url the target address to send the request to
*/
public HttpRequest(HttpMethod httpMethod, URL url) {
this(httpMethod, url, new HttpHeaders(), (RequestContent) null);
this(httpMethod, url, new HttpHeaders(), null);
}

/**
Expand Down Expand Up @@ -60,22 +59,10 @@ public HttpRequest(HttpMethod httpMethod, String url) {
* @param body the request content
*/
public HttpRequest(HttpMethod httpMethod, URL url, HttpHeaders headers, Flux<ByteBuffer> body) {
this(httpMethod, url, headers, new FluxByteBufferContent(body));
}

/**
* Creates a new {@link HttpRequest} instance.
*
* @param httpMethod The HTTP request method.
* @param url The target address to send the request.
* @param headers The HTTP headers of the request.
* @param requestContent The {@link RequestContent}.
*/
public HttpRequest(HttpMethod httpMethod, URL url, HttpHeaders headers, RequestContent requestContent) {
this.httpMethod = httpMethod;
this.url = url;
this.headers = headers;
this.requestContent = requestContent;
this.body = body;
}

/**
Expand Down Expand Up @@ -173,7 +160,7 @@ public HttpRequest setHeader(String name, String value) {
* @return the content to be send
*/
public Flux<ByteBuffer> getBody() {
return (requestContent == null) ? null : requestContent.asFluxByteBuffer();
return body;
}

/**
Expand All @@ -185,7 +172,8 @@ public Flux<ByteBuffer> getBody() {
* @return this HttpRequest
*/
public HttpRequest setBody(String content) {
return setRequestContent(RequestContent.fromString(content));
final byte[] bodyBytes = content.getBytes(StandardCharsets.UTF_8);
return setBody(bodyBytes);
}

/**
Expand All @@ -211,36 +199,7 @@ public HttpRequest setBody(byte[] content) {
* @return this HttpRequest
*/
public HttpRequest setBody(Flux<ByteBuffer> content) {
this.requestContent = new FluxByteBufferContent(content);
return this;
}

/**
* Gets the HttpRequest's {@link RequestContent}.
*
* @return The {@link RequestContent}.
*/
public RequestContent getRequestContent() {
return this.requestContent;
}

/**
* Sets the {@link RequestContent}.
* <p>
* If {@link RequestContent#getLength()} returns null for the passed {@link RequestContent} the caller must set the
* Content-Length header to indicate the length of the content, or use Transfer-Encoding: chunked. Otherwise, {@link
* RequestContent#getLength()} will be used to set the Content-Length header.
*
* @param requestContent The {@link RequestContent}.
* @return The updated HttpRequest object.
*/
public HttpRequest setRequestContent(RequestContent requestContent) {
Long requestContentLength = requestContent.getLength();
if (requestContentLength != null) {
setContentLength(requestContentLength);
}

this.requestContent = requestContent;
this.body = content;
return this;
}

Expand All @@ -259,6 +218,6 @@ private void setContentLength(long contentLength) {
*/
public HttpRequest copy() {
final HttpHeaders bufferedHeaders = new HttpHeaders(headers);
return new HttpRequest(httpMethod, url, bufferedHeaders, requestContent);
return new HttpRequest(httpMethod, url, bufferedHeaders, body);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading