|
67 | 67 | import socket |
68 | 68 | import contextlib |
69 | 69 |
|
70 | | -from binding import Context, HTTPError, AuthenticationError, namespace, UrlEncoded, _encode, _make_cookie_header |
| 70 | +from binding import Context, HTTPError, AuthenticationError, namespace, UrlEncoded, _encode, _make_cookie_header, _NoAuthenticationToken |
71 | 71 | from data import record |
72 | 72 | import data |
73 | 73 |
|
|
100 | 100 | PATH_SAVED_SEARCHES = "saved/searches/" |
101 | 101 | PATH_STANZA = "configs/conf-%s/%s" # (file, stanza) |
102 | 102 | PATH_USERS = "authentication/users/" |
103 | | -PATH_RECEIVERS_STREAM = "receivers/stream" |
104 | | -PATH_RECEIVERS_SIMPLE = "receivers/simple" |
| 103 | +PATH_RECEIVERS_STREAM = "/services/receivers/stream" |
| 104 | +PATH_RECEIVERS_SIMPLE = "/services/receivers/simple" |
105 | 105 | PATH_STORAGE_PASSWORDS = "storage/passwords" |
106 | 106 |
|
107 | 107 | XNAMEF_ATOM = "{http://www.w3.org/2005/Atom}%s" |
@@ -884,7 +884,7 @@ def __contains__(self, item): |
884 | 884 | try: |
885 | 885 | self[item] |
886 | 886 | return True |
887 | | - except KeyError: |
| 887 | + except KeyError, AttributeError: |
888 | 888 | return False |
889 | 889 |
|
890 | 890 | def __eq__(self, other): |
@@ -1937,7 +1937,9 @@ def attach(self, host=None, source=None, sourcetype=None): |
1937 | 1937 | if sourcetype is not None: args['sourcetype'] = sourcetype |
1938 | 1938 | path = UrlEncoded(PATH_RECEIVERS_STREAM + "?" + urllib.urlencode(args), skip_encode=True) |
1939 | 1939 |
|
1940 | | - cookie_or_auth_header = "Authorization: %s\r\n" % self.service.token |
| 1940 | + cookie_or_auth_header = "Authorization: Splunk %s\r\n" % \ |
| 1941 | + (self.service.token if self.service.token is _NoAuthenticationToken |
| 1942 | + else self.service.token.replace("Splunk ", "")) |
1941 | 1943 |
|
1942 | 1944 | # If we have cookie(s), use them instead of "Authorization: ..." |
1943 | 1945 | if self.service.has_cookies(): |
|
0 commit comments