#2407: [patch] CGI Support for django
-------------------------------------------------------+--------------------
   Reporter:  Martin Glueck <[EMAIL PROTECTED]>  |                Owner:  
adrian                
     Status:  new                                      |            Component:  
Core framework        
    Version:  SVN                                      |           Resolution:  
                      
   Keywords:  cgi                                      |                Stage:  
Design decision needed
  Has_patch:  1                                        |           Needs_docs:  
0                     
Needs_tests:  1                                        |   Needs_better_patch:  
1                     
-------------------------------------------------------+--------------------
Comment (by Jedie):

 Yes, you are right. I have not put cgi.py into django/core/servers. I
 saved it into the root and make "from cgi import runcgi"... So i get an
 funny error, because the builtin file was overwritten ;)
 
 Two problems remaining:
 
 1. I must use use the '''{{{environ['PATH_INFO'] =
 environ.get('PATH_INFO',"/")}}}''' fix from above.
 
 2. My http headers was not send in the right order:
    * The first Head line is '''Status: 500 INTERNAL SERVER ERROR'''
    * second line: '''Vary: Cookie'''
    * and the last line: '''Content-Type: text/html'''
 So i have made a silly patch:
 {{{
 #!python
 ...
     def send_content_type(response_headers):
         for no, header in enumerate(response_headers):
             if header[0].lower() == "content-type":
                 sys.stdout.write('%s: %s\r\n' % header)
                 del(response_headers[no])
                 return response_headers
 
         sys.stdout.write('Content-Type: text/html\r\n')
         sys.stdout.write('Warning: Content Type not send!') # Bullshit?!?
 
 
     def write(data):
         if not headers_set:
             raise AssertionError("write() before start_response()")
 
         elif not headers_sent:
             # Before the first output, send the stored headers
             status, response_headers = headers_sent[:] = headers_set
 
             response_headers = send_content_type(response_headers) # Send
 Content-Type first
 
             sys.stdout.write('Status: %s\r\n' % status)
             for header in response_headers:
                 sys.stdout.write('%s: %s\r\n' % header)
             sys.stdout.write('\r\n')
 
         sys.stdout.write(data)
         sys.stdout.flush()
 ...
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2407#comment:13>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to