11/*
2- * Copyright 2013, 2014 Deutsche Nationalbibliothek
2+ * Copyright 2013, 2022 Deutsche Nationalbibliothek et al
33 *
44 * Licensed under the Apache License, Version 2.0 the "License";
55 * you may not use this file except in compliance with the License.
@@ -54,14 +54,14 @@ public final class HttpOpener extends DefaultObjectPipe<String, ObjectReceiver<R
5454
5555 private static final String ACCEPT_HEADER = "accept" ;
5656 private static final String ENCODING_HEADER = "accept-charset" ;
57-
5857 private static final String ACCEPT_DEFAULT = "*/*" ;
58+ private static final String CONTENT_TYPE_HEADER = "content-Type" ;
59+ private static final String CONTENT_TYPE_DEFAULT = "application/json" ;
5960 private static final String ENCODING_DEFAULT = "UTF-8" ;
60-
6161 private static final String INPUT_DESIGNATOR = "@-" ;
62+ private static final String DEFAULT_PREFIX = "ERROR: " ;
6263
6364 private static final Method DEFAULT_METHOD = Method .GET ;
64- private static final String DEFAULT_PREFIX = "ERROR: " ;
6565
6666 private final Map <String , String > headers = new HashMap <>();
6767
@@ -98,6 +98,7 @@ private boolean getInputAsBody() {
9898 */
9999 public HttpOpener () {
100100 setAccept (ACCEPT_DEFAULT );
101+ setContentType (CONTENT_TYPE_DEFAULT );
101102 setEncoding (ENCODING_DEFAULT );
102103 setErrorPrefix (DEFAULT_PREFIX );
103104 setMethod (DEFAULT_METHOD );
@@ -124,6 +125,16 @@ public void setBody(final String body) {
124125 this .body = body ;
125126 }
126127
128+ /**
129+ * Sets the HTTP content type header. This is a mime-type such as text/plain,
130+ * text/html. The default is application/json.
131+ *
132+ * @param contentType mime-type to use for the HTTP contentType header
133+ */
134+ public void setContentType (final String contentType ) {
135+ setHeader (CONTENT_TYPE_HEADER , contentType );
136+ }
137+
127138 /**
128139 * Sets the preferred encoding of the HTTP response. This value is in the
129140 * accept-charset header. Additonally, the encoding is used for reading the
0 commit comments