From 0937d8eadabe2710bf05a964916f857dfaeaa758 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 12 Dec 2019 00:22:54 -0800 Subject: [PATCH] Ignore null headers and allow full url paths (#6760) --- .../src/main/java/com/azure/core/http/rest/RestProxy.java | 2 +- .../com/azure/core/http/rest/SwaggerMethodParser.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java index d9455a941aa2..f9f03d253d7c 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java @@ -232,7 +232,7 @@ private HttpRequest createHttpRequest(SwaggerMethodParser methodParser, Object[] // segment in the host. if (path != null && !path.isEmpty() && !path.equals("/")) { String hostPath = urlBuilder.getPath(); - if (hostPath == null || hostPath.isEmpty() || hostPath.equals("/")) { + if (hostPath == null || hostPath.isEmpty() || hostPath.equals("/") || path.contains("://")) { urlBuilder.setPath(path); } else { urlBuilder.setPath(hostPath + "/" + path); diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/SwaggerMethodParser.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/SwaggerMethodParser.java index 4d6a1e1434f6..a055fa584dc6 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/SwaggerMethodParser.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/SwaggerMethodParser.java @@ -340,12 +340,16 @@ public Iterable setHeaders(Object[] swaggerMethodArguments) { for (final Map.Entry headerCollectionEntry : headerCollection.entrySet()) { final String headerName = headerCollectionPrefix + headerCollectionEntry.getKey(); final String headerValue = serialize(headerCollectionEntry.getValue()); - result.put(headerName, headerValue); + if (headerValue != null) { + result.put(headerName, headerValue); + } } } else { final String headerName = headerSubstitution.getUrlParameterName(); final String headerValue = serialize(methodArgument); - result.put(headerName, headerValue); + if (headerValue != null) { + result.put(headerName, headerValue); + } } } }