@@ -752,11 +752,10 @@ private HttpResponse sendTupleQueryViaHttp(HttpRequest method, Set<QueryResultFo
752752 }
753753 }
754754
755- HttpRequest methodWithAccept = withHeader (method , ACCEPT_PARAM_NAME ,
756- String .join (", " , acceptValues ));
755+ method .addHeader (ACCEPT_PARAM_NAME , String .join (", " , acceptValues ));
757756
758757 try {
759- return executeOK (methodWithAccept );
758+ return executeOK (method );
760759 } catch (RepositoryException | MalformedQueryException | QueryInterruptedException e ) {
761760 throw e ;
762761 } catch (RDF4JException e ) {
@@ -901,11 +900,10 @@ private HttpResponse sendGraphQueryViaHttp(HttpRequest method, boolean requireCo
901900
902901 List <String > acceptParams = RDFFormat .getAcceptParams (rdfFormats , requireContext , getPreferredRDFFormat ());
903902
904- HttpRequest methodWithAccept = withHeader (method , ACCEPT_PARAM_NAME ,
905- String .join (", " , acceptParams ));
903+ method .addHeader (ACCEPT_PARAM_NAME , String .join (", " , acceptParams ));
906904
907905 try {
908- return executeOK (methodWithAccept );
906+ return executeOK (method );
909907 } catch (RepositoryException | MalformedQueryException | QueryInterruptedException e ) {
910908 throw e ;
911909 } catch (RDF4JException e ) {
@@ -972,10 +970,9 @@ private HttpResponse sendBooleanQueryViaHttp(HttpRequest method, Set<QueryResult
972970 }
973971 }
974972
975- HttpRequest methodWithAccept = withHeader (method , ACCEPT_PARAM_NAME ,
976- String .join (", " , acceptValues ));
973+ method .addHeader (ACCEPT_PARAM_NAME , String .join (", " , acceptValues ));
977974
978- return executeOK (methodWithAccept );
975+ return executeOK (method );
979976 }
980977
981978 /**
@@ -1250,19 +1247,4 @@ public void setPassThroughEnabled(boolean passThroughEnabled) {
12501247 this .passThroughEnabled = passThroughEnabled ;
12511248 }
12521249
1253- /**
1254- * Creates a new {@link HttpRequest} with an additional header added to the existing request.
1255- *
1256- * @param request the original request
1257- * @param name the header name
1258- * @param value the header value
1259- * @return a new request with the additional header
1260- */
1261- private static HttpRequest withHeader (HttpRequest request , String name , String value ) {
1262- HttpRequest .Builder builder = HttpRequest .newBuilder (request .getMethod (), request .getUri ())
1263- .headers (request .getHeaders ())
1264- .header (name , value );
1265- request .getBody ().ifPresent (builder ::body );
1266- return builder .build ();
1267- }
12681250}
0 commit comments