code: def jenkins_request_with_headers(
      jenkins_server: Jenkins, req: Request
  ) -> JenkinsRequest | None:
      """Create a Jenkins request from a raw request.
  
      We need to get the headers in addition to the body answer to get the
      location from them. This function uses ``jenkins_request`` from
      python-jenkins with just the return call changed.
  
      :param jenkins_server: The server to query
      :param req: The request to execute
      :return: Dict containing the response body (key body)
          and the headers coming along (headers)
      """
      try:
          response = jenkins_server.jenkins_request(req)
          response_body = response.content
          response_headers = response.headers
          if response_body is None:
              raise jenkins.EmptyResponseException(
                  f"Error communicating with server[{jenkins_server.server}]: empty response"
              )
          return {
              "body": response_body.decode("utf-8"),
              "headers": response_headers,
          }
      except HTTPError as e:
          # Jenkins's funky authentication means its nigh impossible to distinguish errors.
          if e.code in [401, 403, 500]:
              raise JenkinsException(
                  f"Error in request. Possibly authentication failed [{e.code}]: {e.reason}"
              )
          elif e.code == 404:
              raise jenkins.NotFoundException(
                  "Requested item could not be found"
              )
          else:
              raise
      except socket.timeout as e:
          raise jenkins.TimeoutException(f"Error in request: {e}")
      except URLError as e:
          raise JenkinsException(f"Error in request: {e.reason}")
      return None
  
imports: from __future__ import annotations
  import ast
  import json
  import socket
  import time
  from functools import cached_property
  from typing import Any, Iterable, Mapping, Sequence, Union
  from urllib.error import HTTPError, URLError
  import jenkins
  from deprecated.classic import deprecated
  from jenkins import Jenkins, JenkinsException
  from requests import Request
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
  from airflow.models import BaseOperator
  from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
label_desc: Use image node_id 1 for calling a global function with example usage: jenkins_request_with_headers(jenkins_server, req) and returns: None, dict