mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-07 19:03:10 +03:00
Merge pull request #166 from EDCD/fix/165/bad-formencoded-detection
Gateway: Revert non-gzip form encoded check
This commit is contained in:
commit
a4eb7548d9
@ -29,7 +29,7 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
# This apparently causes compression to actually happen
|
# This apparently causes compression to actually happen
|
||||||
s.headers['Content-Encoding'] = 'gzip'
|
s.headers['Content-Encoding'] = 'gzip'
|
||||||
r = s.post(
|
r = s.post(
|
||||||
'https://beta.eddn.edcd.io:4431/upload/',
|
'https://dev.eddn.edcd.io:4432/upload/',
|
||||||
data=msg,
|
data=msg,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
# python `requests` appears to perform compression when you set the
|
# python `requests` appears to perform compression when you set the
|
||||||
# 'Content-Encoding: gzip' header, so do this with curl.
|
# '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/'
|
||||||
|
@ -25,7 +25,7 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
# Send that compressed data as a POST body
|
# Send that compressed data as a POST body
|
||||||
r = http.request(
|
r = http.request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://beta.eddn.edcd.io:4431/upload/',
|
'https://dev.eddn.edcd.io:4432/upload/',
|
||||||
headers={
|
headers={
|
||||||
'Content-Encoding': 'gzip'
|
'Content-Encoding': 'gzip'
|
||||||
},
|
},
|
||||||
|
@ -25,7 +25,7 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
# Send that compressed data as a POST body
|
# Send that compressed data as a POST body
|
||||||
r = http.request(
|
r = http.request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://beta.eddn.edcd.io:4431/upload/',
|
'https://dev.eddn.edcd.io:4432/upload/',
|
||||||
headers={
|
headers={
|
||||||
'Content-Encoding': 'gzip'
|
'Content-Encoding': 'gzip'
|
||||||
},
|
},
|
||||||
|
34
scripts/testing/gateway-responses/test-gzip-plain-json.py
Normal file
34
scripts/testing/gateway-responses/test-gzip-plain-json.py
Normal file
@ -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 <filename>')
|
||||||
|
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')
|
||||||
|
|
@ -20,7 +20,7 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
# Send that data as a POST body
|
# Send that data as a POST body
|
||||||
r = http.request(
|
r = http.request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://beta.eddn.edcd.io:4431/upload/',
|
'https://dev.eddn.edcd.io:4432/upload/',
|
||||||
body=msg
|
body=msg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
# Send that data as a POST body
|
# Send that data as a POST body
|
||||||
r = http.request(
|
r = http.request(
|
||||||
'POST',
|
'POST',
|
||||||
'https://beta.eddn.edcd.io:4431/upload/',
|
'https://dev.eddn.edcd.io:4432/upload/',
|
||||||
body=msg
|
body=msg
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ with open(sys.argv[1], 'r') as f:
|
|||||||
|
|
||||||
s = requests.Session()
|
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'Response: {r!r}')
|
||||||
print(f'Body: {r.content.decode()}')
|
print(f'Body: {r.content.decode()}')
|
||||||
|
@ -166,10 +166,6 @@ def get_decompressed_message():
|
|||||||
else:
|
else:
|
||||||
logger.debug('Content-Encoding indicates *not* compressed...')
|
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
|
# Uncompressed request. Bottle handles all of the parsing of the
|
||||||
# POST key/vals, or un-encoded body.
|
# POST key/vals, or un-encoded body.
|
||||||
data_key = request.forms.get('data')
|
data_key = request.forms.get('data')
|
||||||
@ -178,12 +174,6 @@ def get_decompressed_message():
|
|||||||
# This is a form-encoded POST. Support the silly people.
|
# This is a form-encoded POST. Support the silly people.
|
||||||
message_body = data_key
|
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."
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.debug('Plain POST request detected...')
|
logger.debug('Plain POST request detected...')
|
||||||
# This is a non form-encoded POST body.
|
# This is a non form-encoded POST body.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user