Skip to content

Commit

Permalink
Include User-Agent string for identifying the client
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Sep 4, 2012
1 parent 0c83e83 commit 81a0f90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion raven/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,17 +470,20 @@ def send_encoded(self, message, public_key=None, auth_header=None, **kwargs):
warnings.warn('Raven client has no remote servers configured')
return

client_string = 'raven-python/%s' % (raven.VERSION,)

if not auth_header:
timestamp = time.time()
auth_header = get_auth_header(
protocol=self.protocol_version,
timestamp=timestamp,
client='raven-python/%s' % (raven.VERSION,),
client=client_string,
api_key=public_key or self.public_key
)

for url in self.servers:
headers = {
'User-Agent': client_string,
'X-Sentry-Auth': auth_header,
'Content-Type': 'application/octet-stream',
}
Expand Down
3 changes: 3 additions & 0 deletions tests/client/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_send(self, time, send_remote):
url='http://example.com',
data='eJyrVkrLz1eyUlBKSixSqgUAIJgEVA==',
headers={
'User-Agent': 'raven-python/%s' % (raven.VERSION,),
'Content-Type': 'application/octet-stream',
'X-Sentry-Auth': 'Sentry sentry_timestamp=1328055286.51, '
'sentry_client=raven-python/%s, sentry_version=2.0, sentry_key=public' % (raven.VERSION,)
Expand All @@ -125,6 +126,7 @@ def test_send_with_public_key(self, time, send_remote):
url='http://example.com',
data='eJyrVkrLz1eyUlBKSixSqgUAIJgEVA==',
headers={
'User-Agent': 'raven-python/%s' % (raven.VERSION,),
'Content-Type': 'application/octet-stream',
'X-Sentry-Auth': 'Sentry sentry_timestamp=1328055286.51, '
'sentry_client=raven-python/%s, sentry_version=2.0, sentry_key=foo' % (raven.VERSION,)
Expand All @@ -148,6 +150,7 @@ def test_send_with_auth_header(self, time, send_remote):
url='http://example.com',
data='eJyrVkrLz1eyUlBKSixSqgUAIJgEVA==',
headers={
'User-Agent': 'raven-python/%s' % (raven.VERSION,),
'Content-Type': 'application/octet-stream',
'X-Sentry-Auth': 'foo'
},
Expand Down

0 comments on commit 81a0f90

Please sign in to comment.