mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-05 09:53:03 +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
|
||||
s.headers['Content-Encoding'] = 'gzip'
|
||||
r = s.post(
|
||||
'https://beta.eddn.edcd.io:4431/upload/',
|
||||
'https://dev.eddn.edcd.io:4432/upload/',
|
||||
data=msg,
|
||||
)
|
||||
|
||||
|
@ -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/'
|
||||
|
@ -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'
|
||||
},
|
||||
|
@ -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'
|
||||
},
|
||||
|
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
|
||||
r = http.request(
|
||||
'POST',
|
||||
'https://beta.eddn.edcd.io:4431/upload/',
|
||||
'https://dev.eddn.edcd.io:4432/upload/',
|
||||
body=msg
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
|
||||
|
@ -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()}')
|
||||
|
@ -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...')
|
||||
|
Loading…
x
Reference in New Issue
Block a user