httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Header field update (json output)

Open ehsandeep opened this issue 3 years ago • 0 comments

Please describe your feature request:

When -irr option is used with JSON output, the response header fields contain values for the response header that can be updated to make it more readable/usable for automation and post-processing.

echo scanme.sh | ./httpx -json -silent -irr | jq .

Current format:

  "header": "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Length: 2\r\nContent-Type: text/plain; charset=utf-8\r\nDate: Tue, 30 Aug 2022 12:57:22 GMT\r\n\r\n",

After update:

  "header": {
    "connection": "close",
    "content_length": 2,
    "content_type": "text/plain; charset=utf-8",
    "date": "Tue, 30 Aug 2022 12:57:22 GMT"
  }

Note:

Header keys need to normalize for uniformity:

  • lowercase keys
  • replace - (dash) with _ (underscore) in keys
  • Check if header_raw having original values can be useful

ehsandeep avatar Aug 30 '22 13:08 ehsandeep