Skip to content

Commit 4973bc4

Browse files
committed
pywsus: factorize the SOAP switch case logic
1 parent da396ee commit 4973bc4

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

pywsus.py

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -141,68 +141,37 @@ def do_POST(self):
141141

142142
if soap_action == '"http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetConfig"':
143143
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/b76899b4-ad55-427d-a748-2ecf0829412b
144-
145-
logging.info('SOAP Action: {}'.format(soap_action))
146-
147144
data = BeautifulSoup(update_handler.get_config_xml, 'xml')
148145

149-
self._set_response()
150-
self.wfile.write(data.encode_contents())
151-
152146
elif soap_action == '"http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetCookie"':
153147
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/36a5d99a-a3ca-439d-bcc5-7325ff6b91e2
154-
155-
logging.info('SOAP Action: {}'.format(soap_action))
156-
157148
data = BeautifulSoup(update_handler.get_cookie_xml, "xml")
158149

159-
self._set_response()
160-
self.wfile.write(data.encode_contents())
161-
162150
elif soap_action == '"http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/SyncUpdates"':
163151
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/6b654980-ae63-4b0d-9fae-2abb516af894
164-
165-
logging.info('SOAP Action: {}'.format(soap_action))
166-
167152
data = BeautifulSoup(update_handler.sync_updates_xml, "xml")
168153

169-
self._set_response()
170-
self.wfile.write(data.encode_contents())
171-
172154
elif soap_action == '"http://www.microsoft.com/SoftwareDistribution/Server/ClientWebService/GetExtendedUpdateInfo"':
173155
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/862adc30-a9be-4ef7-954c-13934d8c1c77
174-
175-
logging.info('SOAP Action: {}'.format(soap_action))
176-
177156
data = BeautifulSoup(update_handler.get_extended_update_info_xml, "xml")
178157

179-
self._set_response()
180-
self.wfile.write(data.encode_contents())
181-
182158
elif soap_action == '"http://www.microsoft.com/SoftwareDistribution/ReportEventBatch"':
183159
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/da9f0561-1e57-4886-ad05-57696ec26a78
184-
185-
logging.info(soap_action)
186-
187160
data = BeautifulSoup(update_handler.report_event_batch_xml, "xml")
188161

189-
self._set_response()
190-
self.wfile.write(data.encode_contents())
191-
192162
elif soap_action == '"http://www.microsoft.com/SoftwareDistribution/Server/SimpleAuthWebService/GetAuthorizationCookie"':
193163
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wusp/44767c55-1e41-4589-aa01-b306e0134744
194-
195-
logging.info('SOAP Action: {}'.format(soap_action))
196-
197164
data = BeautifulSoup(update_handler.get_authorization_cookie_xml, "xml")
198165

199-
self._set_response()
200-
self.wfile.write(data.encode_contents())
201-
202166
else:
203-
logging.warning("SOAP Action not defined")
167+
logging.warning("SOAP Action not handled")
168+
logging.info('SOAP Action: {}'.format(soap_action))
204169
return
205170

171+
self._set_response()
172+
self.wfile.write(data.encode_contents())
173+
logging.info('SOAP Action: {}'.format(soap_action))
174+
206175
if data is not None:
207176
logging.debug("POST Response,\nPath: {path}\nHeaders:\n{headers}\n\nBody:\n{body}\n".format(path=self.path, headers=self.headers, body=data.encode_contents))
208177
else:

0 commit comments

Comments
 (0)