// GetHTTPTraffic parses the packets in d []*pkt.Packet looking for *pkt.HttpHdr,
// When one is found we slice that section of the packets to create a new
// HTTPExchange.  The result is a map of httpHdr.RequestURI to HTTPExchange.
// The Data for the HTTPExchange is a slice backed by the same array as d.
//
// For now this is not designed to work well on pipelined responses.
GetHTTPTraffic parses the packets in d []*pkt.Packet looking for *pkt.HttpHdr,
When one is found we slice that section of the packets to create a new
HTTPExchange.  The result is a map of httpHdr.RequestURI to HTTPExchange.
The Data for the HTTPExchange is a slice backed by the same array as d.

For now this is not designed to work well on pipelined responses.
// GetHTTPTraffic parses the packets in d [] * pkt . Packet looking for * pkt . HttpHdr // When one is found we slice that section of the packets to create a new // HTTPExchange . The result is a map of httpHdr . RequestURI to HTTPExchange . // The Data for the HTTPExchange is a slice backed by the same array as d . // // For now this is not designed to work well on pipelined responses .
func GetHTTPTraffic(d []*pkt.Packet) map[string]*HTTPExchange {
	var (
		req       string        
		e         *HTTPExchange 
		httpHdr   *pkt.HttpHdr  
		ok        bool          
		err       error         
		s         int           
		i         int           
		respIndex int           
	)
	m := make(map[string]*HTTPExchange)
	for i = range d {
		if len(d[i].Headers) > ApplicationLayer {
			httpHdr, ok = d[i].Headers[ApplicationLayer].(*pkt.HttpHdr)
			if !ok || httpHdr == nil {
				continue
			}
			if httpHdr.StatusCode == 0 {
				if req != "" {
					e, err = NewHTTPExchange(d[s:i], respIndex-s)
					if err == nil {
						m[req] = e
					}
				}
				s = i
				req = httpHdr.RequestURI
			} else {
				respIndex = i
			}
		}
	}
	e, err = NewHTTPExchange(d[s:i], respIndex-s)
	if err == nil {
		m[req] = e
	}
	return m
}
func GetHTTPTraffic ( d [ ] * pkt . Packet ) map [ string ] * HTTPExchange { var ( req string e * HTTPExchange httpHdr * pkt . HttpHdr ok bool err error s int i int respIndex int ) m := make ( map [ string ] * HTTPExchange ) for i = range d { if len ( d [ i ] . Headers ) > ApplicationLayer { httpHdr , ok = d [ i ] . Headers [ ApplicationLayer ] . ( * pkt . HttpHdr ) if ! ok || httpHdr == nil { continue } if httpHdr . StatusCode == 0 { if req != " " { e , err = NewHTTPExchange ( d [ s : i ] , respIndex - s ) if err == nil { m [ req ] = e } } s = i req = httpHdr . RequestURI } else { respIndex = i } } } e , err = NewHTTPExchange ( d [ s : i ] , respIndex - s ) if err == nil { m [ req ] = e } return m }
GetHTTPTraffic parses the packets in d []*pkt.Packet looking for *pkt.HttpHdr,
When one is found we slice that section of the packets to create a new
HTTPExchange.
GetHTTPTraffic parses the packets in d [] * pkt . Packet looking for * pkt . HttpHdr When one is found we slice that section of the packets to create a new HTTPExchange .
// The unmodified Request-URI (unique in our case) // tmp for *HTTPExchange while checking err // HTTP header - to gather per-packet HTTP data // caste success indicator // any error from NewHTTPExchange // start index of an HTTPExchange // index in d - needed for last HTTPExchange // index of response header // If the next request has the ACK for the // last packet of the previous request this // will cause that ACK to be missing from // the Data in the HTTPExchange.