# getting all headers from http request without using a loop

**URL:** <https://community.f5.com/t/getting-all-headers-from-http-request-without-using-a-loop/8951>\
**Category:** Technical Forums\
**Tags:** irules, devops, application-delivery\
**Created:** [December 4, 2013, 8:19pm UTC](https://community.f5.com/t/getting-all-headers-from-http-request-without-using-a-loop/8951 "2013-12-04T20:19:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![m\_137079](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@m\_137079](https://community.f5.com/u/m_137079)\
**Post date:** [December 4, 2013, 8:19pm UTC](https://community.f5.com/t/getting-all-headers-from-http-request-without-using-a-loop/8951/1 "2013-12-04T20:19:24Z")

</div>

I am using the below irule to get all headers from every http request. Is there any other efficient way to do this for instance without using a loop. Any input is much appreciated

Present Irule

```tcl
when HTTP_REQUEST {

    set HttpHeader " "
    set now [clock format [clock seconds] -format "%D %H:%M:%S %z"]
    set contentlength [HTTP::header "Content-Length"]    

    foreach aHeader [HTTP::header names] {
    append HttpHeader $aHeader ":" [HTTP::header value $aHeader] "\r\n"        
    }           

        HSL::send $applayer_hsl "<190>\r\n$HttpHeader\r\nPath:[URI::path [HTTP::uri]][URI::basename [HTTP::uri]]\r\nQueryStr:[HTTP::query]\r\nHttpKalive:[HTTP::is_keepalive]\r\nHttpVer:[HTTP::version]\r\nF5Addr: [IP::local_addr]\r\nClientIP:[IP::client_addr]\r\nTime:$now\r\nPort:$ClientPort\r\nServer:[LB::server addr]\r\n"
    }

    when CLIENT_ACCEPTED {

    set applayer_hsl [HSL::open -proto UDP -pool hsl_8080_pool]     
    set ClientPort [TCP::local_port] 
   }

```

---

<div class="post-metadata">

**Author:** ![IheartF5\_45022](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@IheartF5\_45022](https://community.f5.com/u/IheartF5_45022)\
**Post date:** [December 5, 2013, 6:21am UTC](https://community.f5.com/t/getting-all-headers-from-http-request-without-using-a-loop/8951/2 "2013-12-05T06:21:48Z")

</div>

Take a look at [HTTP::request]. It dumps the whole request. It’s by far the easiest way to get everything you might want to log, but the format isn’t necessarily what the log trawlers want to see…

---

<div class="post-metadata">

**Author:** ![m\_137079](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@m\_137079](https://community.f5.com/u/m_137079)\
**Post date:** [December 5, 2013, 2:17pm UTC](https://community.f5.com/t/getting-all-headers-from-http-request-without-using-a-loop/8951/3 "2013-12-05T14:17:15Z")

</div>

Nice ! That makes things way simpler. I have a followup question IheartF5. I am using UDP for the HSL and UDP packet size is 64K max. (correct me if I am wrong). So if my http request is more than 64 K I will not get the whole data in one packet and UDP. What can be done in that scenario (I cannot use TCP) Thanks m@ve

---

<div class="post-metadata">

**Author:** ![IheartF5\_45022](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@IheartF5\_45022](https://community.f5.com/u/IheartF5_45022)\
**Post date:** [December 5, 2013, 9:49pm UTC](https://community.f5.com/t/getting-all-headers-from-http-request-without-using-a-loop/8951/4 "2013-12-05T21:49:35Z")

</div>

Remember HTTP:request only logs the request headers, not the payload (if there is one), and given that the default Max Header Size in an http profile is 32768, you are unlikely to exceed 64K.
