Skip to content

Header check failing #108

Closed
Closed
@altho1

Description

@altho1

Describe the bug
When posting a password set to an EA,with no content type in the header, _is_request_payload_buffered fails

To Reproduce
Steps to reproduce the behavior:

  1. Do this post
    result = graph_client.post("/applications/" + id + "/addPassword")
  2. This header is passed to _is_request_payload_buffered
    {'User-Agent': 'python-requests/2.27.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '0', 'Authorization': 'Bearer <token>', 'client-request-id': '<id>', 'sdkVersion': 'graph-python-core/0.2.2 (featureUsage=0x4)', 'HostOs': 'Linux #47~20.04.2-Ubuntu SMP Mon Dec 13 11:06:56 UTC 2021', 'RuntimeEnvironment': 'Python/3.10.1'}
  3. This function fails as it does not check for the existence of Content-Type
    def _is_request_payload_buffered(self, response):
    """
    Checks if the request payload is buffered/rewindable.
    Payloads with forward only streams will return false and have the responses
    returned without any retry attempt.
    """
    if response.request.method.upper() in frozenset(['HEAD', 'GET', 'DELETE', 'OPTIONS']):
    return True
    if response.request.headers['Content-Type'] == "application/octet-stream":
    return False
    return True
  4. changing the offending line to the below, fixes the issue
    if response.request.headers.get('Content-Type') == "application/octet-stream":

Expected behavior
No error

Additional context
Python 3.10.1

autopep8==1.6.0
azure-common==1.1.27
azure-core==1.20.1
azure-functions==1.7.2
azure-identity==1.7.1
azure-keyvault==4.1.0
azure-keyvault-certificates==4.3.0
azure-keyvault-keys==4.4.0
azure-keyvault-secrets==4.3.0
azure-mgmt-containerinstance==9.1.0
azure-mgmt-core==1.3.0
certifi==2021.10.8
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.8
click==8.0.3
cryptography==35.0.0
docx==0.2.4
greenlet==1.1.2
idna==3.3
isodate==0.6.0
joblib==1.1.0
lxml==4.6.4
msal==1.15.0
msal-extensions==0.3.0
msgraph-core==0.2.2
msrest==0.6.21
nltk==3.6.5
numpy==1.21.4
oauthlib==3.1.1
pandas==1.3.4
pdfminer==20191125
Pillow==8.4.0
portalocker==1.7.1
psycopg2-binary==2.9.1
pycairo==1.20.1
pycodestyle==2.8.0
pycparser==2.20
pycryptodome==3.11.0
PyGObject==3.40.1
PyJWT==2.3.0
python-dateutil==2.8.2
python-docx==0.8.11
pytz==2021.3
regex==2021.11.10
requests==2.26.0
requests-oauthlib==1.3.0
six==1.16.0
SQLAlchemy==1.4.26
SQLAlchemy-Utils==0.37.9
toml==0.10.2
tqdm==4.62.3
urllib3==1.26.7

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions