diff --git a/scripts/testing/gateway-responses/test-bad-gzip.py b/scripts/testing/gateway-responses/test-bad-gzip.py index ff5ff11..9d50f1f 100644 --- a/scripts/testing/gateway-responses/test-bad-gzip.py +++ b/scripts/testing/gateway-responses/test-bad-gzip.py @@ -29,7 +29,7 @@ with open(sys.argv[1], 'r') as f: # This apparently causes compression to actually happen s.headers['Content-Encoding'] = 'gzip' r = s.post( - 'https://beta.eddn.edcd.io:4431/upload/', + 'https://dev.eddn.edcd.io:4432/upload/', data=msg, ) diff --git a/scripts/testing/gateway-responses/test-bad-gzip.sh b/scripts/testing/gateway-responses/test-bad-gzip.sh index befde64..77592bf 100644 --- a/scripts/testing/gateway-responses/test-bad-gzip.sh +++ b/scripts/testing/gateway-responses/test-bad-gzip.sh @@ -3,4 +3,4 @@ # python `requests` appears to perform compression when you set the # 'Content-Encoding: gzip' header, so do this with curl. -curl --verbose -d 'wegiuweuygtfawgep9aqe8fpq2387lfbr;iufvypq38764tpgf' -H 'Content-Encoding: gzip' 'https://beta.eddn.edcd.io:4431/upload/' +curl --verbose -d 'wegiuweuygtfawgep9aqe8fpq2387lfbr;iufvypq38764tpgf' -H 'Content-Encoding: gzip' 'https://dev.eddn.edcd.io:4432/upload/' diff --git a/scripts/testing/gateway-responses/test-gzip-bad-formdata.py b/scripts/testing/gateway-responses/test-gzip-bad-formdata.py index 0ae79fd..0e3e1f0 100644 --- a/scripts/testing/gateway-responses/test-gzip-bad-formdata.py +++ b/scripts/testing/gateway-responses/test-gzip-bad-formdata.py @@ -25,7 +25,7 @@ with open(sys.argv[1], 'r') as f: # Send that compressed data as a POST body r = http.request( 'POST', - 'https://beta.eddn.edcd.io:4431/upload/', + 'https://dev.eddn.edcd.io:4432/upload/', headers={ 'Content-Encoding': 'gzip' }, diff --git a/scripts/testing/gateway-responses/test-gzip-correct-formdata.py b/scripts/testing/gateway-responses/test-gzip-correct-formdata.py index 066f617..e58c1d9 100644 --- a/scripts/testing/gateway-responses/test-gzip-correct-formdata.py +++ b/scripts/testing/gateway-responses/test-gzip-correct-formdata.py @@ -25,7 +25,7 @@ with open(sys.argv[1], 'r') as f: # Send that compressed data as a POST body r = http.request( 'POST', - 'https://beta.eddn.edcd.io:4431/upload/', + 'https://dev.eddn.edcd.io:4432/upload/', headers={ 'Content-Encoding': 'gzip' }, diff --git a/scripts/testing/gateway-responses/test-gzip-plain-json.py b/scripts/testing/gateway-responses/test-gzip-plain-json.py new file mode 100644 index 0000000..db7042a --- /dev/null +++ b/scripts/testing/gateway-responses/test-gzip-plain-json.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import json +import requests +import sys +import urllib3 +import zlib + +if len(sys.argv) != 2: + print('test-sender.py ') + sys.exit(-1) + +with open(sys.argv[1], 'r') as f: + # Read from provided file + msg = f.read() + + # Compress it + msg_gzip = zlib.compress(msg.encode('utf-8')) + + http = urllib3.PoolManager() + + # Send that compressed data as a POST body + r = http.request( + 'POST', + 'https://dev.eddn.edcd.io:4432/upload/', + headers={ + 'Content-Encoding': 'gzip' + }, + body=msg_gzip + ) + + print(f'Response: {r.status!r}') + print(f'Body:\n{r.data.decode()}\n') + diff --git a/scripts/testing/gateway-responses/test-plain-bad-formdata.py b/scripts/testing/gateway-responses/test-plain-bad-formdata.py index f0fccb4..04cc0bd 100644 --- a/scripts/testing/gateway-responses/test-plain-bad-formdata.py +++ b/scripts/testing/gateway-responses/test-plain-bad-formdata.py @@ -20,7 +20,7 @@ with open(sys.argv[1], 'r') as f: # Send that data as a POST body r = http.request( 'POST', - 'https://beta.eddn.edcd.io:4431/upload/', + 'https://dev.eddn.edcd.io:4432/upload/', body=msg ) diff --git a/scripts/testing/gateway-responses/test-plain-correct-formdata.py b/scripts/testing/gateway-responses/test-plain-correct-formdata.py index 99ccf63..a00815f 100644 --- a/scripts/testing/gateway-responses/test-plain-correct-formdata.py +++ b/scripts/testing/gateway-responses/test-plain-correct-formdata.py @@ -20,7 +20,7 @@ with open(sys.argv[1], 'r') as f: # Send that data as a POST body r = http.request( 'POST', - 'https://beta.eddn.edcd.io:4431/upload/', + 'https://dev.eddn.edcd.io:4432/upload/', body=msg ) diff --git a/scripts/testing/gateway-responses/test-sender.py b/scripts/testing/gateway-responses/test-sender.py index 8bd9cde..de563a7 100644 --- a/scripts/testing/gateway-responses/test-sender.py +++ b/scripts/testing/gateway-responses/test-sender.py @@ -13,7 +13,7 @@ with open(sys.argv[1], 'r') as f: s = requests.Session() - r = s.post('https://beta.eddn.edcd.io:4431/upload/', data=msg) + r = s.post('https://dev.eddn.edcd.io:4432/upload/', data=msg) print(f'Response: {r!r}') print(f'Body: {r.content.decode()}') diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index ee360f1..d9e7dfd 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -166,23 +166,13 @@ def get_decompressed_message(): else: logger.debug('Content-Encoding indicates *not* compressed...') - form_enc_parsed = urlparse.parse_qs(request.body.read()) - if form_enc_parsed: - logger.debug('Request is form-encoded') - - # Uncompressed request. Bottle handles all of the parsing of the - # POST key/vals, or un-encoded body. - data_key = request.forms.get('data') - if data_key: - logger.debug('form-encoded POST request detected...') - # This is a form-encoded POST. Support the silly people. - message_body = data_key - - else: - raise MalformedUploadError( - "No 'data' POST key/value found. Check your POST key " - "name for spelling, and make sure you're passing a value." - ) + # Uncompressed request. Bottle handles all of the parsing of the + # POST key/vals, or un-encoded body. + data_key = request.forms.get('data') + if data_key: + logger.debug('form-encoded POST request detected...') + # This is a form-encoded POST. Support the silly people. + message_body = data_key else: logger.debug('Plain POST request detected...')