From fd4ef66b75a52a04152861256ef6abe6215d46d0 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Mon, 2 Jul 2018 16:03:40 +0100 Subject: [PATCH] Simplify parsing of HTTP headers in fetch-url operation Closes #1669 and makes it possible to specify other headers via the JSON representation of the operation. --- .../ColumnAdditionByFetchingURLsOperation.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java b/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java index d231fad04..3b69179fb 100644 --- a/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java +++ b/main/src/com/google/refine/operations/column/ColumnAdditionByFetchingURLsOperation.java @@ -338,16 +338,12 @@ public class ColumnAdditionByFetchingURLsOperation extends EngineDependentOperat try { URLConnection urlConnection = url.openConnection(); if (_httpHeadersJson != null) { - Map httpHeaders = new HashMap<>(); - for (int i = 0; i < _httpHeadersJson.length(); i++) { + for (int i = 0; i < _httpHeadersJson.length(); i++) { String headerLabel = _httpHeadersJson.getJSONObject(i).getString("name"); String headerValue = _httpHeadersJson.getJSONObject(i).getString("value"); - httpHeaders.put(headerLabel, headerValue); - } - for (String headerLabel : HttpHeadersSupport.getHttpHeaderLabels()) { - HttpHeaderInfo info = HttpHeadersSupport.getHttpHeaderInfo(headerLabel); - - urlConnection.setRequestProperty(info.header, httpHeaders.get(headerLabel)); + if (headerValue != null && !headerValue.isEmpty()) { + urlConnection.setRequestProperty(headerLabel, headerValue); + } } }