All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.rules.headers.URLConnectionHeadersAdapter Maven / Gradle / Ivy

Go to download

Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly identify, troubleshoot and fix failed builds. This artifact contains the classes to instrument the Java NET package.

There is a newer version: 0.15.1-beta.2
Show newest version
package com.undefinedlabs.scope.rules.headers;

import com.undefinedlabs.scope.rules.http.HttpHeadersAdapter;
import com.undefinedlabs.scope.deps.org.apache.commons.lang3.StringUtils;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class URLConnectionHeadersAdapter implements HttpHeadersAdapter {

    private final Map> headers;

    public URLConnectionHeadersAdapter(final Map> headers) {
        this.headers = headers;
    }

    @Override
    public Iterable> iterator() {
        if (headers == null) {
            return Collections.unmodifiableMap(new HashMap()).entrySet();
        }

        final Map headersMap = new HashMap<>();
        for (Map.Entry> entry : headers.entrySet()) {
            if (entry.getValue() != null && entry.getValue().size() > 0) {
                headersMap.put(entry.getKey(), StringUtils.join(entry.getValue(), "|"));
            }
        }

        return Collections.unmodifiableMap(headersMap).entrySet();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy