Changeset 22073fe6c9d9e1d2c037bcb175d8f73c5a0f7b0f

Show
Ignore:
Timestamp:
04/03/06 11:46:27 (3 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1141469187 +0000
git-parent:

[b2c73bd478662d7bdb47e96e40458b7035451472]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1141469187 +0000
Message:

Cosmetic

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/network/httpd.c

    r31683ca r22073fe  
    22 * httpd.c 
    33 ***************************************************************************** 
    4  * Copyright (C) 2004-2005 the VideoLAN team 
     4 * Copyright (C) 2004-2006 the VideoLAN team 
    55 * $Id$ 
    66 * 
     
    2727 
    2828#ifdef ENABLE_HTTPD 
     29 
     30#include <assert.h> 
    2931 
    3032#include "vlc_httpd.h" 
     
    295297} 
    296298 
     299#if 0 
     300typedef struct 
     301{ 
     302    int i_code; 
     303    const char *psz_reason; 
     304} http_status_info; 
     305 
     306static const http_status_info http_reason[] = 
     307{ 
     308  /*{ 100, "Continue" }, 
     309    { 101, "Switching Protocols" },*/ 
     310    { 200, "OK" }/*, 
     311    { 201, "Created" }, 
     312    { 202, "Accepted" }, 
     313    { 203, "Non-Authoritative Information" }, 
     314    { 204, "No Content" }, 
     315    { 205, "Reset Content" }, 
     316    { 206, "Partial Content" }, 
     317    { 250, "Low on Storage Space" }, 
     318    { 300, "Multiple Choices" }*/, 
     319    { 301, "Moved Permanently" }/*, 
     320    { 302, "Moved Temporarily" }, - aka "Found" 
     321    { 303, "See Other" }, 
     322    { 304, "Not Modified" }, 
     323    { 305, "Use Proxy" }, 
     324    { 307, "Temporary Redirect" }, 
     325    { 400, "Bad Request" }*/, 
     326    { 401, "Unauthorized" }/*, 
     327    { 402, "Payment Required" }*/, 
     328    { 403, "Forbidden" }, 
     329    { 404, "Not Found" }/*, 
     330    { 405, "Method Not Allowed" }, 
     331    { 406, "Not Acceptable" }, 
     332    { 407, "Proxy Authentication Required" }, 
     333    { 408, "Request Time-out" }, 
     334    { 409, "Conflict" }, 
     335    { 410, "Gone" }, 
     336    { 411, "Length Required" }, 
     337    { 412, "Precondition Failed" }, 
     338    { 413, "Request Entity Too Large" }, 
     339    { 414, "Request-URI Too Large" }, 
     340    { 415, "Unsupported Media Type" }, 
     341    { 416, "Requested range not satisfiable" }, 
     342    { 417, "Expectation Failed" }, 
     343    { 451, "Parameter Not Understood" }, 
     344    { 452, "Conference Not Found" }, 
     345    { 453, "Not Enough Bandwidth" }*/, 
     346    { 454, "Session Not Found" }/*, 
     347    { 455, "Method Not Valid in This State" }, 
     348    { 456, "Header Field Not Valid for Resource" }, 
     349    { 457, "Invalid Range" }, 
     350    { 458, "Parameter Is Read-Only" }, 
     351    { 459, "Aggregate operation not allowed" }, 
     352    { 460, "Only aggregate operation allowed" }*/, 
     353    { 461, "Unsupported transport" }/*, 
     354    { 462, "Destination unreachable" }*/, 
     355    { 500, "Internal Server Error" }, 
     356    { 501, "Not Implemented" }/*, 
     357    { 502, "Bad Gateway" }*/, 
     358    { 503, "Service Unavailable" }/*, 
     359    { 504, "Gateway Time-out" }, 
     360    { 505, "Protocol version not supported" }*/, 
     361    {   0, NULL } 
     362}; 
     363 
     364static const char *psz_fallback_reason[] = 
     365{ "Continue", "OK", "Found", "Client Error", "Server Error" }; 
     366 
     367static const char *httpd_ReasonFromCode( int i_code ) 
     368{ 
     369    const http_status_info *p; 
     370 
     371    for (p = http_reason; p->i_code < i_code; p++); 
     372 
     373    if( p->i_code == i_code ) 
     374        return p->psz_reason; 
     375 
     376    assert( ( i_code >= 100 ) && ( i_code <= 599 ) ); 
     377    return psz_fallback_reason[(i_code / 100) - 1]; 
     378} 
     379#endif 
     380 
    297381/***************************************************************************** 
    298382 * High Level Functions: httpd_file_t 
     
    569653{ 
    570654    httpd_redirect_t *rdir = (httpd_redirect_t*)p_sys; 
    571     uint8_t *p; 
    572655 
    573656    if( answer == NULL || query == NULL ) 
     
    581664    answer->psz_status = strdup( "Moved Permanently" ); 
    582665 
    583     p = answer->p_body = malloc( 1000 + strlen( rdir->psz_dst ) ); 
    584     p += sprintf( (char *)p, 
     666    answer->i_body = asprintf( (char **)&answer->p_body, 
    585667        "<?xml version=\"1.0\" encoding=\"ascii\" ?>\n" 
    586668        "<!DOCTYPE html PUBLIC \"-//W3C//DTD  XHTML 1.0 Strict//EN\" " 
     
    591673        "</head>\n" 
    592674        "<body>\n" 
    593         "<h1>You should be "  
     675        "<h1>You should be " 
    594676        "<a href=\"%s\">redirected</a></h1>\n" 
    595677        "<hr />\n" 
     
    598680        "</body>\n" 
    599681        "</html>\n", rdir->psz_dst ); 
    600     answer->i_body = p - answer->p_body; 
    601682 
    602683    /* XXX check if it's ok or we need to set an absolute url */ 
     
    690771        { 
    691772            /* this client isn't fast enough */ 
     773#if 0 
    692774            fprintf( stderr, "fixing i_body_offset (old=%lld new=%lld)\n", 
    693775                     answer->i_body_offset, stream->i_buffer_last_pos ); 
     776#endif 
    694777            answer->i_body_offset = stream->i_buffer_last_pos; 
    695778        }