File tree Expand file tree Collapse file tree
main/java/jenkins/plugins/http_request
test/java/jenkins/plugins/http_request Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,9 +124,10 @@ public InputStream getContentStream() {
124124 private void readCharset (ClassicHttpResponse response ) {
125125 Charset charset = null ;
126126
127+ Header contentTypeHeader = response .getFirstHeader (HttpHeaders .CONTENT_TYPE );
127128 ContentType contentType = ContentType .parse (response .getEntity () != null ?
128129 response .getEntity ().getContentType () :
129- response . getFirstHeader ( HttpHeaders . CONTENT_TYPE ). getValue ());
130+ ( contentTypeHeader != null ? contentTypeHeader . getValue () : null ));
130131 if (contentType != null ) {
131132 charset = contentType .getCharset ();
132133 if (charset == null ) {
Original file line number Diff line number Diff line change @@ -990,6 +990,18 @@ void responseContentSupplierHeadersCaseInsensitivity() throws Exception {
990990 respSupplier .close ();
991991 }
992992
993+ @ Test
994+ void responseContentSupplierHandlesNoContentTypeHeader () throws Exception {
995+ // Prepare test context - 204 No Content response without Content-Type header
996+ CloseableHttpResponse response = HttpResponseAdapter .adapt (new BasicClassicHttpResponse (204 , "No Content" ));
997+ // Don't set entity or Content-Type header to simulate GitHub API 204 response
998+ // Run test
999+ ResponseContentSupplier respSupplier = new ResponseContentSupplier (ResponseHandle .NONE , response );
1000+ // Check expectations - should not throw NullPointerException
1001+ assertEquals (204 , respSupplier .getStatus ());
1002+ respSupplier .close ();
1003+ }
1004+
9931005 @ Test
9941006 void testFileUpload () throws Exception {
9951007 // Prepare the server
You can’t perform that action at this time.
0 commit comments