Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add None type check for content_type #1748

Closed
wants to merge 1 commit into from
Closed

Add None type check for content_type #1748

wants to merge 1 commit into from

Conversation

codingjoe
Copy link

@codingjoe codingjoe commented Mar 24, 2017

If the Content-Type header is not set, content_type will be None.
We should not perform a string operation on None.

AttributeError: 'NoneType' object has no attribute 'startswith'
  File "laas/server.py", line 47, in middleware_handler
    return await handler(request)
  File "laas/server.py", line 22, in handle
    data = await request.post()
  File "aiohttp/web_request.py", line 412, in post
    if content_type.startswith('text/'):

What do these changes do?

Are there changes in behavior for the user?

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new entry to CHANGES.rst
    • Choose any open position to avoid merge conflicts with other PRs.
    • Add a link to the issue you are fixing (if any) using #issue_number format at the end of changelog message. Use Pull Request number if there are no issues for PR or PR covers the issue only partially.

If the Content-Type header is not set, content_type will be None.
We should not perform a string operation on None.
```
AttributeError: 'NoneType' object has no attribute 'startswith'
  File "laas/server.py", line 47, in middleware_handler
    return await handler(request)
  File "laas/server.py", line 22, in handle
    data = await request.post()
  File "aiohttp/web_request.py", line 412, in post
    if content_type.startswith('text/'):
```
@kxepal
Copy link
Member

kxepal commented Mar 24, 2017

Looks like duplicate of #1743

@codingjoe
Copy link
Author

@kxepal thx it is

@codingjoe codingjoe closed this Mar 24, 2017
@codingjoe codingjoe deleted the patch-1 branch March 24, 2017 13:52
hredestig added a commit to DD-DeCaF/upload-legacy that referenced this pull request Apr 10, 2017
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants