Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68154

Custom headers with special characters in their names

      According to the documentation of the plugin, you can define custom headers for requests with a syntax like this one:

      def response = httpRequest customHeaders: [[name: 'foo', value: 'bar']]
      

      The problem arises when you try to use custom headers that use names with non-standard characters. I can't see the way to do something like this:

      def response = httpRequest customHeaders: [["my-custom-header-with-hyphen-separator": "${varName}"]]

      I know I can do it the hard way:

      def headers = new ArrayList<jenkins.plugins.http_request.util.HttpRequestNameValuePair>()
      
      def headerName1 = 'my-custom-header-with-hyphen-separator'
      def varName1 = 'abc'
      
      headers.add(new jenkins.plugins.http_request.util.HttpRequestNameValuePair("${headerName1}","${varName1}"))
      

      However I don't think that's the preferred method as it involves granting certain permissions to scripts.

      Under normal circumstances, I would've expected here to use this kind of syntax:

      def headers = [ "${headerName1}":"${varName1}","${headerName2}": "${varName2}" ]
      

      Pretty much a json object with one or more key/value pairs.

      So, is this possible? is there any alternative syntax that can be used right now to avoid working directly with Java classes?

       

          [JENKINS-68154] Custom headers with special characters in their names

          I have an implementation ready for this improvement but awaiting feedback from a JEP-200 ticket I have opened because there might be security concerns:
          https://issues.jenkins.io/browse/JENKINS-71075

          Christos Fitsialis added a comment - I have an implementation ready for this improvement but awaiting feedback from a JEP-200 ticket I have opened because there might be security concerns: https://issues.jenkins.io/browse/JENKINS-71075

          Pratik added a comment - - edited

          markewaite janario aquesada Can I work on this issue ?

          Pratik added a comment - - edited markewaite janario aquesada Can I work on this issue ?

          Mark Waite added a comment -

          pratik_0112 you are welcome to work on it. Thanks for noting your interest,

          Mark Waite added a comment - pratik_0112 you are welcome to work on it. Thanks for noting your interest,

          Pratik added a comment - - edited

           markewaite Sir,

          • Recently I created PR on this issue, when I see that syntax for pipeline for expected custom headers was build successfully in my jenkins controller (also mentioned in PR)
          • Yes, I know that build process had failed for test cases & can bee seen at CI of jenkins in PR
          • I am going to look over issue, why they are failing
          • But before proceeding, I want some suggestion from you, instead of taking any wrong path to look over the error

          Pratik added a comment - - edited   markewaite Sir, Recently I created PR on this issue, when I see that syntax for pipeline for expected custom headers was build successfully in my jenkins controller (also mentioned in PR) Yes, I know that build process had failed for test cases & can bee seen at CI of jenkins in PR I am going to look over issue, why they are failing But before proceeding, I want some suggestion from you, instead of taking any wrong path to look over the error

            pratik_0112 Pratik
            aquesada Alfredo Quesada
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: