HUE-5717 [backend] Some operating system incorrectly detect javascript mime-type as text/x-js instead of application/javascript

Review Request #9397 — Created Jan. 24, 2017 and discarded

ranade
hue
master
HUE-5717
hue
enricoberti, jennykim, johan, krish, ranade, romain, subrata, weixia
commit af90bd1e9e598f3355ea493169d824f1be4a9d34
Author: Prakash Ranade <ranade@cloudera.com>
Date:   Mon Jan 30 17:49:05 2017 -0800

    HUE-5717 [backend] Some operating system incorrectly detect javascript mime-type as text/x-js instead of application/javascript

:100644 100644 f24b63f... d65d919... M	desktop/core/src/desktop/middleware.py
:100644 100644 eea9b36... 2f52cf3... M	desktop/core/src/desktop/settings.py

tested on SLES and CentOS. Make sure Hue django server port works.

  • 4
  • 0
  • 0
  • 0
  • 4
Description From Last Updated
Add a final . and SLES11 as example? romain romain
Good everywhere, e.g on Mac? romain romain
And maybe even simpler, is there a lib in Python 2.6 to do this? https://docs.python.org/2/library/mimetypes.html#mimetypes.guess_extension romain romain
nit: bit more Pythonic with not: if not filter(lambda line: line.rstrip().endswith('js') and line.rstrip().startswith('text/x-js'), f.readlines()): romain romain
romain
  1. And how about replacing the mime type text/x-js --> application/javascript in a middleware? (to avoid most of the custom logic here)

    1. In my opinion putting this logic in urls.py(controller) is better then putting it in middleware(request/response processing). As middleware has onion/layered execution chain and could slow down processing.

    2. 'As middleware has onion/layered execution chain and could slow down processing.' what is the perf difference vs potential bugs/maintenance of above?

    3. please explain what is potential bugs/maintenance above? In function "javascript_gen" the code generates straight forward "HttpResponse" in middleware execution chain, I may/may not cut the layered execution and generate straight "HttpResponse"

  2. 
      
ranade
ranade
romain
  1. 
      
  2. desktop/core/src/desktop/middleware.py (Diff revision 3)
     
     

    Add a final . and SLES11 as example?

  3. desktop/core/src/desktop/middleware.py (Diff revision 3)
     
     

    Good everywhere, e.g on Mac?

  4. desktop/core/src/desktop/middleware.py (Diff revision 3)
     
     

    nit: bit more Pythonic with not:

    if not filter(lambda line: line.rstrip().endswith('js') and
    line.rstrip().startswith('text/x-js'),
    f.readlines()):

  5. 
      
romain
  1. 
      
  2. desktop/core/src/desktop/middleware.py (Diff revision 3)
     
     

    And maybe even simpler, is there a lib in Python 2.6 to do this?

    https://docs.python.org/2/library/mimetypes.html#mimetypes.guess_extension

  3. 
      
ranade
Review request changed

Status: Discarded

Loading...