Skip to content

Use UriBuilder when creating HttpRequest.setUri in annotation processor #45201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ public static HostEdgeCase1Service getNewInstance(HttpPipeline httpPipeline) {
@SuppressWarnings("cast")
@Override
public byte[] getByteArray(String url, int numberOfBytes) {
String uri = url + "/bytes/" + numberOfBytes;
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes/" + numberOfBytes);
// Send the request through the httpPipeline
try (Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest)) {
int responseCode = networkResponse.getStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ public static HostEdgeCase2Service getNewInstance(HttpPipeline httpPipeline) {
@SuppressWarnings("cast")
@Override
public byte[] getByteArray(String uri, int numberOfBytes) {
String requestUri = uri + "/bytes/" + numberOfBytes;
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(requestUri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri + "/bytes/" + numberOfBytes);
// Send the request through the httpPipeline
try (Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest)) {
int responseCode = networkResponse.getStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ public static ParameterizedHostService getNewInstance(HttpPipeline httpPipeline)
@SuppressWarnings("cast")
@Override
public byte[] getByteArray(String scheme, String host, int numberOfBytes) {
String uri = scheme + "://" + host + "/bytes/" + numberOfBytes;
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(scheme + "://" + host + "/bytes/" + numberOfBytes);
// Send the request through the httpPipeline
try (Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest)) {
int responseCode = networkResponse.getStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ public static ParameterizedMultipleHostService getNewInstance(HttpPipeline httpP
@SuppressWarnings("cast")
@Override
public HttpBinJSON get(String scheme, String hostPart1, String hostPart2) {
String uri = scheme + "://" + hostPart1 + hostPart2 + "/get";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(scheme + "://" + hostPart1 + hostPart2 + "/get");
// Send the request through the httpPipeline
Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest);
int responseCode = networkResponse.getStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ public static SimpleXmlSerializableService getNewInstance(HttpPipeline httpPipel
@SuppressWarnings("cast")
@Override
public void sendApplicationXml(SimpleXmlSerializable simpleXmlSerializable) {
String uri = "http://localhost/sendApplicationXml";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.PUT).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.PUT).setUri("http://localhost/sendApplicationXml");
httpRequest.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/xml");
if (simpleXmlSerializable != null) {
SerializationFormat serializationFormat = CoreUtils.serializationFormatFromContentType(httpRequest.getHeaders());
Expand All @@ -78,9 +77,8 @@ public void sendApplicationXml(SimpleXmlSerializable simpleXmlSerializable) {
@SuppressWarnings("cast")
@Override
public void sendTextXml(SimpleXmlSerializable simpleXmlSerializable) {
String uri = "http://localhost/sendTextXml";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.PUT).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.PUT).setUri("http://localhost/sendTextXml");
httpRequest.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "text/xml");
if (simpleXmlSerializable != null) {
SerializationFormat serializationFormat = CoreUtils.serializationFormatFromContentType(httpRequest.getHeaders());
Expand All @@ -105,9 +103,8 @@ public void sendTextXml(SimpleXmlSerializable simpleXmlSerializable) {
@SuppressWarnings("cast")
@Override
public SimpleXmlSerializable getXml(String contentType) {
String uri = "http://localhost/getXml";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri("http://localhost/getXml");
if (contentType != null) {
httpRequest.getHeaders().add(new HttpHeader(HttpHeaderName.CONTENT_TYPE, contentType));
}
Expand Down Expand Up @@ -136,9 +133,8 @@ public SimpleXmlSerializable getXml(String contentType) {
@SuppressWarnings("cast")
@Override
public SimpleXmlSerializable getInvalidXml(String contentType) {
String uri = "http://localhost/getInvalidXml";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri("http://localhost/getInvalidXml");
if (contentType != null) {
httpRequest.getHeaders().add(new HttpHeader(HttpHeaderName.CONTENT_TYPE, contentType));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ public static SpecialReturnBodiesService getNewInstance(HttpPipeline httpPipelin
@SuppressWarnings("cast")
@Override
public BinaryData getBinaryData(String url) {
String uri = url + "/bytes";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes");
// Send the request through the httpPipeline
Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest);
int responseCode = networkResponse.getStatusCode();
Expand All @@ -65,9 +64,8 @@ public BinaryData getBinaryData(String url) {
@SuppressWarnings("cast")
@Override
public Response<BinaryData> getBinaryDataWithResponse(String url) {
String uri = url + "/bytes";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes");
// Send the request through the httpPipeline
Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest);
int responseCode = networkResponse.getStatusCode();
Expand All @@ -83,9 +81,8 @@ public Response<BinaryData> getBinaryDataWithResponse(String url) {
@SuppressWarnings("cast")
@Override
public byte[] getByteArray(String url) {
String uri = url + "/bytes";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes");
// Send the request through the httpPipeline
try (Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest)) {
int responseCode = networkResponse.getStatusCode();
Expand All @@ -102,9 +99,8 @@ public byte[] getByteArray(String url) {
@SuppressWarnings("cast")
@Override
public Response<byte[]> getByteArrayWithResponse(String url) {
String uri = url + "/bytes";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes");
// Send the request through the httpPipeline
try (Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest)) {
int responseCode = networkResponse.getStatusCode();
Expand All @@ -121,9 +117,8 @@ public Response<byte[]> getByteArrayWithResponse(String url) {
@SuppressWarnings("cast")
@Override
public InputStream getInputStream(String url) {
String uri = url + "/bytes";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes");
// Send the request through the httpPipeline
Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest);
int responseCode = networkResponse.getStatusCode();
Expand All @@ -139,9 +134,8 @@ public InputStream getInputStream(String url) {
@SuppressWarnings("cast")
@Override
public Response<InputStream> getInputStreamWithResponse(String url) {
String uri = url + "/bytes";
// Create the HTTP request
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(uri);
// Create the HttpRequest.
HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.GET).setUri(url + "/bytes");
// Send the request through the httpPipeline
Response<BinaryData> networkResponse = this.httpPipeline.send(httpRequest);
int responseCode = networkResponse.getStatusCode();
Expand Down
Loading
Loading