Skip to content

Commit

Permalink
BUG: mail url collector: handle empty download
Browse files Browse the repository at this point in the history
fixes #988
  • Loading branch information
Sebastian Wagner committed May 14, 2018
1 parent 81163d5 commit 3b0c336
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG

### Bots
#### Collectors
- `bots.collectors.mail.collector_mail_url`: handle empty downloaded reports (#988).

#### Parsers
- Shadowserver parser:
Expand Down
16 changes: 9 additions & 7 deletions intelmq/bots/collectors/mail/collector_mail_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ def process(self):
if resp.status_code // 100 != 2:
raise ValueError('HTTP response status code was {}.'
''.format(resp.status_code))
if not resp.content:
self.logger.warning('Got empty reponse from server.')
else:
self.logger.info("Report downloaded.")

self.logger.info("Report downloaded.")
template = self.new_report()

template = self.new_report()

for report in generate_reports(template, io.BytesIO(resp.content),
self.chunk_size,
self.chunk_replicate_header):
self.send_message(report)
for report in generate_reports(template, io.BytesIO(resp.content),
self.chunk_size,
self.chunk_replicate_header):
self.send_message(report)

# Only mark read if message relevant to this instance,
# so other instances watching this mailbox will still
Expand Down

0 comments on commit 3b0c336

Please sign in to comment.