@Test public void multipleHeadersWithTheSameNameShouldBeAddedToCurlCommand() { final Request request = new Request.Builder() .url("http: .addHeader("Cookie", "FIRST=foo") .addHeader("Cookie", "SECOND=bar") .build(); final String command = new CurlBuilder(request).build(); assertEquals("curl -X GET -H \"Cookie:FIRST=foo\" -H \"Cookie:SECOND=bar\" \"http: }
public String build() { List<String> parts = new ArrayList<>(); parts.add("curl"); parts.addAll(options); parts.add(String.format(FORMAT_METHOD, method.toUpperCase())); for (Header header : headers) { final String headerPart = String.format(FORMAT_HEADER, header.name(), header.value()); parts.add(headerPart); } if (contentType != null && !containsName(CONTENT_TYPE, headers)) { parts.add(String.format(FORMAT_HEADER, CONTENT_TYPE, contentType)); } if (body != null) { parts.add(String.format(FORMAT_BODY, body)); } parts.add(String.format(FORMAT_URL, url)); return join(delimiter, parts); }
CurlBuilder { public String build() { List<String> parts = new ArrayList<>(); parts.add("curl"); parts.addAll(options); parts.add(String.format(FORMAT_METHOD, method.toUpperCase())); for (Header header : headers) { final String headerPart = String.format(FORMAT_HEADER, header.name(), header.value()); parts.add(headerPart); } if (contentType != null && !containsName(CONTENT_TYPE, headers)) { parts.add(String.format(FORMAT_HEADER, CONTENT_TYPE, contentType)); } if (body != null) { parts.add(String.format(FORMAT_BODY, body)); } parts.add(String.format(FORMAT_URL, url)); return join(delimiter, parts); } }
CurlBuilder { public String build() { List<String> parts = new ArrayList<>(); parts.add("curl"); parts.addAll(options); parts.add(String.format(FORMAT_METHOD, method.toUpperCase())); for (Header header : headers) { final String headerPart = String.format(FORMAT_HEADER, header.name(), header.value()); parts.add(headerPart); } if (contentType != null && !containsName(CONTENT_TYPE, headers)) { parts.add(String.format(FORMAT_HEADER, CONTENT_TYPE, contentType)); } if (body != null) { parts.add(String.format(FORMAT_BODY, body)); } parts.add(String.format(FORMAT_URL, url)); return join(delimiter, parts); } CurlBuilder(Request request);  CurlBuilder(Request request, long limit, List<HeaderModifier> headerModifiers, Options options);  CurlBuilder(Request request, long limit, List<HeaderModifier> headerModifiers, Options options, String delimiter); }
CurlBuilder { public String build() { List<String> parts = new ArrayList<>(); parts.add("curl"); parts.addAll(options); parts.add(String.format(FORMAT_METHOD, method.toUpperCase())); for (Header header : headers) { final String headerPart = String.format(FORMAT_HEADER, header.name(), header.value()); parts.add(headerPart); } if (contentType != null && !containsName(CONTENT_TYPE, headers)) { parts.add(String.format(FORMAT_HEADER, CONTENT_TYPE, contentType)); } if (body != null) { parts.add(String.format(FORMAT_BODY, body)); } parts.add(String.format(FORMAT_URL, url)); return join(delimiter, parts); } CurlBuilder(Request request);  CurlBuilder(Request request, long limit, List<HeaderModifier> headerModifiers, Options options);  CurlBuilder(Request request, long limit, List<HeaderModifier> headerModifiers, Options options, String delimiter); String build(); }
CurlBuilder { public String build() { List<String> parts = new ArrayList<>(); parts.add("curl"); parts.addAll(options); parts.add(String.format(FORMAT_METHOD, method.toUpperCase())); for (Header header : headers) { final String headerPart = String.format(FORMAT_HEADER, header.name(), header.value()); parts.add(headerPart); } if (contentType != null && !containsName(CONTENT_TYPE, headers)) { parts.add(String.format(FORMAT_HEADER, CONTENT_TYPE, contentType)); } if (body != null) { parts.add(String.format(FORMAT_BODY, body)); } parts.add(String.format(FORMAT_URL, url)); return join(delimiter, parts); } CurlBuilder(Request request);  CurlBuilder(Request request, long limit, List<HeaderModifier> headerModifiers, Options options);  CurlBuilder(Request request, long limit, List<HeaderModifier> headerModifiers, Options options, String delimiter); String build();  }