invernizzi / scapy-http

Support for HTTP in Scapy
Other
301 stars 77 forks source link

Problen referencing a field in the HTTP headers #7

Closed omribentov closed 10 years ago

omribentov commented 10 years ago

Hi,

I'm trying to user scapy_http, but I have a problem of referncing fields that have a "-" in them.

So doing something like pkt[HTTPRequest].Host is OK, but pkt[HTTPRequest].User-Agent is not.

I saw that in Steeve Barbeau's original code he used different lists for the fields_rfc(e.g. User-Agent) and the fields_desc(UserAgent), thus allowing to reference the user agent by pkt[HTTPRequest].UserAgent.

Is there a way to do something like this ???

Tnx,

Omri

invernizzi commented 10 years ago

Hi Omri, I've decided to go for 'User-Agent' (because I expect it to be written that way :) ). This choice does have this drawback, but it's easily fixed like so:

print pkt[HTTPRequest].fields['User-Agent']

prints out

'Wget/1.13.4 (linux-gnu)'
omribentov commented 10 years ago

Thanks, I didn't know the syntax.

On Wed, Jul 23, 2014 at 1:14 PM, Luca Invernizzi notifications@github.com wrote:

Hi Omri, I've decided to go for 'User-Agent' (because I expect it to be written that way :) ). This choice does have this drawback, but it's easily fixed like so:

print pkt[HTTPRequest].fields['User-Agent']

prints out

'Wget/1.13.4 (linux-gnu)'

— Reply to this email directly or view it on GitHub https://github.com/invernizzi/scapy-http/issues/7#issuecomment-49855834.