Your IP : 216.73.216.134


Current Path : /opt/rh/rh-python35/root/lib64/python3.5/http/__pycache__/
Upload File :
Current File : //opt/rh/rh-python35/root/lib64/python3.5/http/__pycache__/server.cpython-35.pyc



���\���@sbdZdZddddgZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZd	Zd
Zdd�ZGd
d�de
j�ZGdd�de
j�ZGdd�de�Zdd�Zdadd�Zdd�Z Gdd�de�Z!eeddddd�Z"e#dkr^ej$�Z%e%j&dddd d!�e%j&d"d#d$dd%d&d d'�e%j&d(dd)d$dd*e'd+d,d d-�e%j(�Z)e)j*r9e!Z+neZ+e"d.e+d(e)j,d/e)j-�dS)0a@HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6�
HTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8cCs(|jdd�jdd�jdd�S)N�&z&amp;�<z&lt;�>z&gt;)�replace)�html�r�;/opt/rh/rh-python35/root/usr/lib64/python3.5/http/server.py�_quote_html�src@s"eZdZdZdd�ZdS)r�cCsNtjj|�|jj�dd�\}}tj|�|_||_dS)z.Override server_bind to store the server name.N�)�socketserver�	TCPServer�server_bind�socket�getsocknameZgetfqdn�server_name�server_port)�self�host�portrrr
r�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressrrrrr
r�sc
@s�eZdZdZdejj�dZdeZ	e
ZeZ
dZdd�Zdd	�Zd
d�Zdd
�Zdddd�Zddd�Zddd�Zdd�Zdd�Zdd�Zdddd�Zdd�Zd d!�Zd"d#�Zdd$d%�Zd&d'�Zd(d)d*d+d,d-d.gZdd/d0d1d2d3d4d5d6d7d8d9d:g
Z d;d<�Z!d=Z"e#j$j%Z&d>d?�e'j(j)�D�Z*dS)@ra�HTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/zHTTP/0.9c
Cs/d|_|j|_}d|_t|jd�}|jd�}||_|j�}t	|�dkr�|\}}}|dd�dkr�|j
tjd|�d	Sya|jd
d�d}|jd�}t	|�d
kr�t
�t|d�t|d�f}Wn3t
tfk
r@|j
tjd|�d	SYnX|dkre|jdkred	|_|dkr|j
tjd|�d	Snvt	|�d
kr�|\}}d|_|dkr|j
tjd|�d	Sn%|s�d	S|j
tjd|�d	S||||_|_|_y%tjj|jd|j�|_Wn/tjjk
rx|j
tjd�d	SYnX|jjdd�}|j�dkr�d|_n*|j�dkr�|jdkr�d	|_|jjdd�}	|	j�dkr+|jdkr+|jdkr+|j�s+d	SdS)a'Parse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, an
        error is sent back.

        NTz
iso-8859-1z
��zHTTP/zBad request version (%r)F�/r�.rrzHTTP/1.1zInvalid HTTP Version (%s)ZGETzBad HTTP/0.9 request type (%r)zBad request syntax (%r)Z_classz
Line too long�
Connection��closez
keep-aliveZExpectz100-continue)rr)rr)�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
send_errorrZBAD_REQUEST�
ValueError�int�
IndexError�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLong�get�lower�handle_expect_100)
r�versionr,�wordsr%r4Zbase_version_numberZversion_numberZconntypeZexpectrrr
�
parse_request	s�			$					z$BaseHTTPRequestHandler.parse_requestcCs|jtj�|j�dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        T)�send_response_onlyrZCONTINUE�end_headers)rrrr
r<ds
z(BaseHTTPRequestHandler.handle_expect_100cCs,y�|jjd�|_t|j�dkr\d|_d|_d|_|jtj	�dS|jsrd|_
dS|j�s�dSd|j}t||�s�|jtj
d|j�dSt||�}|�|jj�WnEtjk
r'}z"|jd|�d|_
dSWYdd}~XnXdS)	z�Handle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iir#NTZdo_zUnsupported method (%r)zRequest timed out: %r)r7�readliner*r.r,r'r%r/rZREQUEST_URI_TOO_LONGr(r?�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushrZtimeout�	log_error)rZmname�method�errr
�handle_one_requestvs4					
	z)BaseHTTPRequestHandler.handle_one_requestcCs1d|_|j�x|js,|j�qWdS)z&Handle multiple requests if necessary.TN)r(rK)rrrr
�handle�s	
zBaseHTTPRequestHandler.handleNcCsLy|j|\}}Wntk
r7d\}}YnX|dkrJ|}|dkr\|}|jd||�|jd|dt|�dt|�i}|jdd�}|j||�|jd	|j�|jd
d�|jdt	t
|���|j�|jd
krH|dkrH|t
jt
jfkrH|jj|�dS)akSend and log an error reply.

        Arguments are
        * code:    an HTTP error code
                   3 digits
        * message: a simple optional 1 line reason phrase.
                   *( HTAB / SP / VCHAR / %x80-FF )
                   defaults to short entry matching the response code
        * explain: a detailed message defaults to the long entry
                   matching the response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        �???Nzcode %d, message %s�code�message�explainzUTF-8r
zContent-Typer"r$zContent-LengthZHEAD��)rMrM)�	responses�KeyErrorrH�error_message_formatr�encode�
send_response�send_header�error_content_typer1r.rAr%rZ
NO_CONTENTZNOT_MODIFIEDrF�write)rrNrOrPZshortmsgZlongmsgZcontentZbodyrrr
r/�s,
%
z!BaseHTTPRequestHandler.send_errorcCsM|j|�|j||�|jd|j��|jd|j��dS)z�Add the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        ZServerZDateN)�log_requestr@rW�version_string�date_time_string)rrNrOrrr
rV�s
z$BaseHTTPRequestHandler.send_responsecCs�|dkr5||jkr/|j|d}nd}|jdkr�t|d�s\g|_|jjd|j||fjdd��dS)	zSend the response header only.Nrr#zHTTP/0.9�_headers_bufferz
%s %d %s
zlatin-1�strict)rRr'rCr]�appendr3rU)rrNrOrrr
r@�s	z)BaseHTTPRequestHandler.send_response_onlycCs�|jdkrMt|d�s'g|_|jjd||fjdd��|j�dkr�|j�dkr}d|_n|j�d	kr�d
|_dS)z)Send a MIME header to the headers buffer.zHTTP/0.9r]z%s: %s
zlatin-1r^Z
connectionr$Tz
keep-aliveFN)r'rCr]r_rUr;r()r�keyword�valuerrr
rW�s		z"BaseHTTPRequestHandler.send_headercCs-|jdkr)|jjd�|j�dS)z,Send the blank line ending the MIME headers.zHTTP/0.9s
N)r'r]r_�
flush_headers)rrrr
rA�sz"BaseHTTPRequestHandler.end_headerscCs8t|d�r4|jjdj|j��g|_dS)Nr]�)rCrFrY�joinr])rrrr
rb�sz$BaseHTTPRequestHandler.flush_headers�-cCsAt|t�r|j}|jd|jt|�t|��dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)�
isinstancerra�log_messager,r))rrN�sizerrr
rZs		z"BaseHTTPRequestHandler.log_requestcGs|j||�dS)z�Log an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)rg)r�format�argsrrr
rH
sz BaseHTTPRequestHandler.log_errorcGs1tjjd|j�|j�||f�dS)a�Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        z%s - - [%s] %s
N)�sys�stderrrY�address_string�log_date_time_string)rrirjrrr
rgs		z"BaseHTTPRequestHandler.log_messagecCs|jd|jS)z*Return the server software version string.� )�server_version�sys_version)rrrr
r[1sz%BaseHTTPRequestHandler.version_stringc	Css|dkrtj�}tj|�\	}}}}}}}}	}
d|j|||j|||||f}|S)z@Return the current date and time formatted for a message header.Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�timeZgmtime�weekdayname�	monthname)rZ	timestamp�year�month�day�hh�mm�ssZwd�y�z�srrr
r\5s*
z'BaseHTTPRequestHandler.date_time_stringc	Cs]tj�}tj|�\	}}}}}}}}	}
d||j|||||f}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)rrZ	localtimert)rZnowrurvrwrxryrz�xr{r|r}rrr
rn@s
* z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs|jdS)zReturn the client address.r)�client_address)rrrr
rmNsz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCs%i|]}|j|jf|�qSr)�phraseZdescription)�.0�vrrr
�
<dictcomp>]s	z!BaseHTTPRequestHandler.<dictcomp>)+rrr�__doc__rkr=r-rq�__version__rp�DEFAULT_ERROR_MESSAGErT�DEFAULT_ERROR_CONTENT_TYPErXr&r?r<rKrLr/rVr@rWrArbrZrHrgr[r\rnrsrtrmr3r5r6ZHTTPMessager8rZ__members__�valuesrRrrrr
r�s>f
[%+
		c	@s�eZdZdZdeZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Ze
js�e
j�e
jj�Zejddddddddi�dS)raWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/c
Cs;|j�}|r7z|j||j�Wd|j�XdS)zServe a GET request.N)�	send_head�copyfilerFr$)r�frrr
�do_GETrs
zSimpleHTTPRequestHandler.do_GETcCs |j�}|r|j�dS)zServe a HEAD request.N)r�r$)rr�rrr
�do_HEAD{sz SimpleHTTPRequestHandler.do_HEADc	Cs�|j|j�}d}tjj|�r
tjj|j�}|jjd�s�|jt	j
�|d|d|dd|d|df}tjj|�}|jd|�|j
�dSxIdD]4}tjj||�}tjj|�r�|}Pq�W|j|�S|j|�}yt|d�}Wn)tk
rW|jt	jd�dSYnXy}|jt	j�|jd
|�tj|j��}|jdt|d��|jd|j|j��|j
�|SWn|j��YnXdS)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nr rrrr�ZLocation�
index.html�	index.htm�rbzFile not foundzContent-typezContent-Length�z
Last-Modified)r�r�)�translate_pathr4�os�isdir�urllib�parseZurlsplit�endswithrVrZMOVED_PERMANENTLYZ
urlunsplitrWrArd�exists�list_directory�
guess_type�open�OSErrorr/�	NOT_FOUND�OK�fstat�filenor)r\�st_mtimer$)	rr4r��partsZ	new_partsZnew_url�indexZctypeZfsrrr
r��sF



	

z"SimpleHTTPRequestHandler.send_headc
Cs`ytj|�}Wn)tk
r>|jtjd�dSYnX|jddd��g}ytjj	|j
dd�}Wn$tk
r�tjj	|�}YnXtj
|�}tj�}d|}|jd	�|jd
�|jd|�|jd|�|jd
|�|jd�x�|D]�}tj
j||�}|}	}
tj
j|�rr|d}	|d}
tj
j|�r�|d}	|jdtjj|
dd�tj
|	�f�q'W|jd�dj|�j|d�}tj�}|j|�|jd�|jtj�|jdd|�|jdtt|���|j�|S)z�Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        zNo permission to list directoryN�keycSs
|j�S)N)r;)�arrr
�<lambda>�sz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>�errors�
surrogatepasszDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r �@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperzContent-typeztext/html; charset=%szContent-Length) r��listdirr�r/rr��sortr�r��unquoter4�UnicodeDecodeErrorr�escaperk�getfilesystemencodingr_rdr��islinkZquoterU�io�BytesIOrY�seekrVr�rWr)r.rA)
rr4�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrr
r��s\
	




	





	



z'SimpleHTTPRequestHandler.list_directorycCsB|jdd�d}|jdd�d}|j�jd�}ytjj|dd�}Wn$tk
r�tjj|�}YnXtj|�}|jd�}t	d|�}t
j�}xn|D]f}t
jj
|�\}}t
jj|�\}}|t
jt
jfkrq�t
jj||�}q�W|r>|d7}|S)	z�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        �?rr�#r r�r�N)r-r+r�r�r�r�r��	posixpath�normpath�filterr��getcwdr4�
splitdrive�curdir�pardirrd)rr4Ztrailing_slashr>ZwordZdrive�headrrr
r��s(	


z'SimpleHTTPRequestHandler.translate_pathcCstj||�dS)a�Copy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)�shutilZcopyfileobj)r�sourceZ
outputfilerrr
r�
sz!SimpleHTTPRequestHandler.copyfilecCsdtj|�\}}||jkr/|j|S|j�}||jkrU|j|S|jdSdS)a�Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        r#N)r��splitext�extensions_mapr;)rr4�baseZextrrr
r�sz#SimpleHTTPRequestHandler.guess_typer#zapplication/octet-streamz.pyz
text/plainz.cz.hN)rrrr�r�rpr�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��updaterrrr
rcs"
	1:	
c	Cs+|jd�\}}}tjj|�}|jd�}g}xP|dd�D]>}|dkro|j�qP|rP|dkrP|j|�qPW|r�|j�}|r�|dkr�|j�d}q�|dkr�d}nd}|r�dj||f�}ddj|�|f}dj|�}|S)	a�
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a collapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: The reconstituted URL, which will always start with a '/'.

    Raises: IndexError if too many '..' occur within the path.

    r�r Nrz..r!r#���)�	partitionr�r�r�r-�popr_rd)	r4�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr
�_url_collapse_path?s.

		r�cCs�tr
tSyddl}Wntk
r2dSYnXy|jd�daWn5tk
r�dtdd�|j�D��aYnXtS)	z$Internal routine to get nobody's uidrNr�nobodyrcss|]}|dVqdS)rNr)r�r~rrr
�	<genexpr>}sznobody_uid.<locals>.<genexpr>r�)r��pwd�ImportError�getpwnamrS�maxZgetpwall)r�rrr
�
nobody_uidqs
	
(r�cCstj|tj�S)zTest for executable file.)r��access�X_OK)r4rrr
�
executable�sr�c@seZdZdZeed�ZdZdd�Zdd�Z	dd	�Z
d
dgZdd
�Zdd�Z
dd�ZdS)rz�Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    �forkrcCs0|j�r|j�n|jtjd�dS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)�is_cgi�run_cgir/rrD)rrrr
�do_POST�s

zCGIHTTPRequestHandler.do_POSTcCs'|j�r|j�Stj|�SdS)z-Version of send_head that support CGI scriptsN)r�r�rr�)rrrr
r��s
zCGIHTTPRequestHandler.send_headcCslt|j�}|jdd�}|d|�||dd�}}||jkrh||f|_dSdS)a3Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).

        r rNTF)r�r4�find�cgi_directories�cgi_info)rr�Zdir_sepr��tailrrr
r��s%zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCs
t|�S)z1Test whether argument path is an executable file.)r�)rr4rrr
�
is_executable�sz#CGIHTTPRequestHandler.is_executablecCs(tjj|�\}}|j�dkS)z.Test whether argument path is a Python script.�.py�.pyw)r�r�)r�r4r�r;)rr4r�r�rrr
�	is_python�szCGIHTTPRequestHandler.is_pythonc)Cs�|j\}}|d|}|jdt|�d�}x�|dkr�|d|�}||dd�}|j|�}tjj|�r�||}}|jdt|�d�}q<Pq<W|jd�\}}}	|jd�}|dkr|d|�||d�}
}n
|d}
}|d|
}|j|�}tjj|�sl|j	t
jd|�dStjj|�s�|j	t
j
d|�dS|j|�}
|js�|
r�|j|�s�|j	t
j
d	|�dStjtj�}|j�|d
<|jj|d<d|d
<|j|d<t|jj�|d<|j|d<tjj|�}||d<|j|�|d<||d<|	r�|	|d<|jd|d<|jj d�}|r�|j!�}t|�dkr�ddl"}ddl#}|d|d<|dj$�dkr�y/|dj%d�}|j&|�j'd�}Wn|j(t)fk
rfYn0X|j!d�}t|�dkr�|d|d<|jj d�dkr�|jj*�|d<n|jd|d<|jj d�}|r�||d <|jj d!�}|r||d"<g}xc|jj+d#�D]O}|dd�d$krd|j,|j-��q2||d%d�j!d&�}q2Wd&j.|�|d'<|jj d(�}|r�||d)<t/d|jj0d*g��}d+j.|�}|r�||d,<xd@D]}|j1|d�q�W|j2t
j3d.�|j4�|	j5d/d0�}|jr�|
g}d1|krr|j,|�t6�}|j7j8�tj9�}|dkrtj:|d�\}}x9t;j;|j<gggd�dr�|j<j=d�s�Pq�W|r
|j>d2|�dSyoytj?|�Wnt@k
r6YnXtjA|j<jB�d�tjA|j7jB�d�tjC|||�Wq�|jjD|jE|j�tjFd3�Yq�XnddlG} |g}!|j|�r!tHjI}"|"j$�jJd4�r|"ddA�|"dBd�}"|"d7g|!}!d1|	kr:|!j,|	�|jKd8| jL|!��ytM|�}#WntNtOfk
r�d}#YnX| jP|!d9| jQd:| jQd;| jQd<|�}$|jj$�d=kr�|#dkr�|j<j=|#�}%nd}%x?t;j;|j<jRgggd�dr1|j<jRjSd�s�Pq�W|$jT|%�\}&}'|j7jU|&�|'rm|j>d>|'�|$jVjW�|$jXjW�|$jY}(|(r�|j>d2|(�n
|jKd?�dS)CzExecute a CGI script.r rrNr�r#zNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationrZ	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE�REMOTE_HOSTzScript output follows�+ro�=zCGI script exit status %#x�zw.exerr�z-uzcommand: %s�stdin�stdoutrl�envZpostz%szCGI script exited OK)r�r�r�r�r�r�������)Zr�r�r.r�r�r4r�r�r�r/rr��isfileZ	FORBIDDENr��	have_forkr�r��deepcopy�environr[Zserverrr3r)rr%r�r�r�rr9r:r-�base64�binasciir;rUZdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersr_�striprdr�Zget_all�
setdefaultrVr�rbr
r�rFrGr��waitpid�selectr7�readrH�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrkr�r�rgZlist2cmdliner1�	TypeErrorr0�Popen�PIPEZ_sockZrecvZcommunicaterYrlr$r��
returncode))r�dir�restr4�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyrZuqrestr�rrZlengthr�r��lineZua�coZ
cookie_str�kZ
decoded_queryrjr��pid�stsrZcmdlineZinterp�nbytes�p�datar�rlZstatusrrr
r��s4
$









!



		
	
%
		
				!(

	zCGIHTTPRequestHandler.run_cgiN)rrrr�rCr�rZrbufsizer�r�r�r�r�r�r�rrrr
r�szHTTP/1.0i@r#cCs�||f}||_|||�}|jj�}td|dd|dd�y|j�Wn3tk
r�td�|j�tjd�YnXdS)zmTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the port argument).

    zServing HTTP onrrrz...z&
Keyboard interrupt received, exiting.N)	r3rr�printZ
serve_forever�KeyboardInterruptZserver_closerk�exit)�HandlerClassZServerClassZprotocolr�bindZserver_addressZhttpdZsarrr
�test�s	


r*�__main__z--cgi�action�
store_true�helpzRun as CGI Serverz--bindz-b�default�metavarZADDRESSz8Specify alternate bind address [default: all interfaces]rZstore�type�nargsr�z&Specify alternate port [default: 8000]r(r)).r�r��__all__rZhttp.clientr5r�r�r�r�rr�rrrkrrZurllib.parser�r��argparserr�r�rrrZStreamRequestHandlerrrr�r�r�r�rr*r�ArgumentParser�parser�add_argumentr1�
parse_argsrjZcgiZ
handler_classrr)rrrr
�<module> sb3���0�
		

Rosenblum TV: Video training, virtual workshops, classes, tutorials
logologologologo
  • About
  • What We Do
  • Our Clients
  • Case Studies
    • The BBC
    • CBS News
    • New York Times Television
    • Spectrum News
    • The Newark Star-Ledger
    • The United Nations
    • McGraw/Hill
    • Oyster Yachts
    • Scottish Environmental Protection Agency
  • The Power of Storytelling
  • Why iPhones?
  • Michael on Media
  • Books
  • Contact
  • About
  • What We Do
  • Our Clients
  • Case Studies
    • The BBC
    • CBS News
    • New York Times Television
    • Spectrum News
    • The Newark Star-Ledger
    • The United Nations
    • McGraw/Hill
    • Oyster Yachts
    • Scottish Environmental Protection Agency
  • The Power of Storytelling
  • Why iPhones?
  • Michael on Media
  • Books
  • Contact

RE-INVENTING THE TELEVISION NEWS BUSINESS*

A revolution in video storytelling

Creating entirely new & cost-effective production methods

From the world leaders in video production training and the creators of Character Driven Storytelling™

*and every other business that uses video

WHAT WE DO

Over the past 35 years, we have designed, built or restructured some of the most powerful news and journalism companies in the world.

We replace the traditional TV news ‘crew’ with one highly trained journalist, working alone with nothing but an iPhone.

No more TV news ‘crews’, no editors and no field producers.

This is television news done the way newspaper journalism is done – one reporter with their electronic pad and pencil.

In doing this, we can cut the cost of production by as much as 75% while increasing ratings and audience engagement.

In the place of conventional TV news ‘packages’ – ie, reporter stand up, interview, b-roll, man on the street, we marry great journalism with Netflix and Hollywood storytelling.

It’s a combination that works.

We have taken most of our clients to #1 in their respective markets.

And it’s not just for news. Any company, any profit, any NGO and anyone else who is online needs to tell their story in compelling yet cost-effective video. We can teach you to do that. Either in person or virtually.

EXAMPLES OF WHAT WE CAN TEACH YOUR STAFF TO PRODUCE

ITAY HOD

Itay Hod, MMJ with KPIX/CBS in San Francisco, took the 5-Day Intensive Video Storytelling Bootcamp in 2018.

Because he works alone, with only an iPhone, he was able to embed himself with a homeless family.

Here’s the story he produced in a one-day turn.

KIET DO

Kiet Do, an MMJ with KPIX/CBS in San Francisco, took the 5-Day Intensive Video Storytelling Bootcamp in 2021.

Here is a story he produced, all on his own, with only an iPhone and in a one-day turn.

TAYLOR SCHAUB

Taylor Schaub, an MMJ with Spectrum News 1 in LA, took the 5-Day Intensive Video Storytelling Bootcamp in 2023.

Here is a story he turned in only one day, using only an iPhone. It was the first video story he ever did and it was nominated for an Emmy.

THE BOOTCAMP

How do we convert stations and whole networks to working in this way?

Since 1988, we have run intensive 5-Day Video Storytelling Bootcamps

We have done these all over the world.

These are hands-on bootcamps, and participants learn an entirely new way of creating TV news stories.

-We shoot at a 3:1 ratio or lower, so turnaround times are fast.

-We go directly from camera to timelilne and edit – no written scripts.  We work in the medium of pictures and sound.

-We are entirely character-driven.

-We are driven by pictures and real events.

-We are focused almost entirely on ’the viewer experience’.

Since 1988, more than 70,000 journalists around the world have taken our bootcamps, either in person on virtualy.

Case Studies

CBS Case Study Logos
CBS News

We have started to work with CBS News, bringing our ideas of character-driven storytelling to one of the most successful and biggest networks in the United States. Since beginning to work with them ratings have climbed and more importantly, audience engagement is through the ceiling.

Learn More
NYT Case Study Logos
New York Times Television

We started New York Times Television in 1990 and it was the first paper to be brought into the world of TV. It quickly became one of the most successful non-fiction production companies in the United States. The series and documentaries we produced won many awards including multiple Emmys.

Learn More
BBC Case Study Logos
The BBC

We have been working with the BBC since the year 2000 helping to convert their national news network to our visual storytelling technique. Most recently we have trained teams from their sports, documentaries, and comedy divisions to make character-driven stories using only smartphones.

Learn More
Spectrum Case Study Logos
Spectrum News

For the past five years we have worked with Spectrum News to introduce and train their journalists on visual, character driven storytelling using smartphones helping to create a different kind of local news for their network of 24-Hour News Stations across the United States.

Learn More
UN Case Study Logos
The United Nations

In 2006, we were approached by the United Nations. Rather than rely on news outlets, it would be much easier to train the field operatives to produce their own stories. We spent two years working with the UN, training more than 100 of their staff in bootcamps in Geneva and Nairobi.

Learn More
Star Ledger Case Study Logos
The Newark Star-Ledger

We trained 50 print reporters at the paper to shoot and tell their own stories, in conjunction with their print work. We built a TV newsroom in their existing print newsroom – you could not ask for a better set and they began to live stream their stories in conjunction with their print work.

Learn More
Mcgraw Hill Case Study Logos
Mcgraw Hill

We spent two years with McGraw Hill, training more than 150 of their staffers, making them completely video literate. McGraw/Hill media properties we transit included Business Week, Aviation Week, (what was the name of the architecture magazine), and JD Power and Associates.

Learn More
VOA Case Study Logos
Voice of America

In 1990, we were approached by The Voice of America, the official broadcasting agency for the United States Government. When we met with VOA, they were only a short wave radio broadcaster, but working with them, we took them into television, launching VOA-TV.

Learn More
Oyster Case Study Logos
Oyster Yachts

British based Oyster Yachts makes some of the finest yachts in the world. Like every other company, they had to find a way to feed the never-ending video demands of social media – sites like Instagram and TikTok. We trained the Oyster staff to tell their own stories, using only iPhones.

Learn More
SEPA Case Study Logos
Scottish Environmental Protection Agency

We were approached by SEPA, the Scottish Environmental Protection Agency because they had to continually find a way to ‘feed the media beast’. The result was that SEPA was able to tell their own stories, whenever they wanted, and at almost no additional cost.

Learn More
Image 11-11-22 at 6.25 PM

Michael on Media

Michael Rosenblum has been writing about the media since 1988. His work and ideas have appeared in The Guardian, The Huffington Post, Ilkeston Life and many other publications.

He has been blogging regularly for the past 35 years on this subject. Having taught media studies at Columbia University, NYU and now the University of Oxford, he is considered an expert on this subject.

Continue reading this post or look back at previous posts.

Read More

Do You Have Questions About Learning Video Skills?

If you would like to know more about our courses contact us and one of our training advisors will be happy to call you.

Contact Us

Copyright 2024. All rights reserved.