How to reference http request header with a dash in the index name

if I loop through the get request to the agent with the code below I get a human-readable output listing all of the header indices and values. One of them is “accept-encoding” and it is different from some others due to the “-” in the name. This causes a run time error if I try to reference it directly. Is there a syntax correction or other method that would allow this to be referenced?


foreach(idx,val in request.headers){
server.log(“index= “+idx+” value= “+val+”
server.log ("accept is " + request.headers.accept);
//server.log ("accept is " + request.headers.accept-encoding);//produces an error


... [Agent] index= accept-encoding value= gzip,deflate,sdch .... [Agent] index= connection value= keep-alive [Agent] index= accept value= application/json, text/javascript, */*; q=0.01 [Agent] index= x-forwarded-for value= myipaddress [Agent] index= user-agent value= Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.66 Safari/537.36 .... [Agent] accept is application/json, text/javascript, */*; q=0.01 ...<b></b>

if I uncomment that last line then I also get this in the response.

.... [Agent] the index 'encoding' does not exist [Agent] at unknown:30 ...