Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accept invalid media types with just a warning.

  • Loading branch information...
commit 4c35f7ab1b7024daadd49aaa4fbcb982339f66d0 1 parent 0c142ac
Andrew Fleenor authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 pcap2har/mediatype.py
View
12 pcap2har/mediatype.py
@@ -32,9 +32,7 @@ def __init__(self, data):
if not data:
logging.warning(
'Setting empty media type to x-unknown-content-type')
- self.type = 'application'
- self.subtype = 'x-unknown-content-type'
- params = {}
+ self.set_unknown()
return
match = self.mediatype_re.match(data)
if match:
@@ -52,7 +50,13 @@ def __init__(self, data):
self.params[pairmatch.group(1)] = pairmatch.group(2)
pass
else:
- raise ValueError('invalid media type string: ' + data)
+ logging.warning('Invalid media type string: "%s"' % data)
+ self.set_unknown()
+
+ def set_unknown(self):
+ self.type = 'application'
+ self.subtype = 'x-unknown-content-type'
+ self.params = {}
def mimeType(self):
return '%s/%s' % (self.type, self.subtype)
Please sign in to comment.
Something went wrong with that request. Please try again.