QWebView+cgi



  • Hi,
    i have a cgi, firefox, konqueror and chrome showing is in correct mode, instead QWebVIew show nothing! QWebInspector report blank page.
    My cgi code is:
    @
    printf("Content-Type:text/html\n\n");
    fid=fopen("/usr/lib/cgi-bin/top_template.html","r");
    while(fgets(string,256,fid)!=NULL)
    printf("%s",string);
    fclose(fid);

        printf("<br>\n");
    

    printf("<form name="dcontrol" action="/cgi-bin/dcontrol" method="GET">\n");
    printf("<input type="hidden" name="NoData" value="1"/>\n");
    //printf("<input type="text" value=" Monitor off"/>\n");
    printf("<p><strong>");
    printf("my string     ");
    printf("</strong></p>\n");
    printf("<input type="submit" value="Update"/>\n");
    printf("</form>\n");

    fid=fopen("bottom_template.html","r");
    while(fgets(string,256,fid)!=NULL)
    printf("%s",string);
    fclose(fid);
    @

    What's happen?



  • Can you dump (GET -es, telnet, netcat, LiveHTTPHeaders...) and paste here a complete response from the server?



  • @
    GET /cgi-bin/dcontrol
    Monitor Spento.
    Content-Type:text/html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html >
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Presidium</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link href="/default.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="wrapper">
    <!-- start header -->
    <div id="logo">
    <h1> &nbsp<a href="/tm_ui/main_page.html"><img src="/images/logo_presidium.png"></a></h1>
    </div>
    <div id="header">
    <div id="menu">
    <ul>
    <li><a href="/terminal.html">Home</a></li>
    <li><a href="/cgi-bin/ccontrol">Dati</a></li>
    <li><a href="/cgi-bin/dcontrol">V100</a></li>
    <li><a href="/tm_ui/main_page.html">Menu</a></li>
    </ul>
    </div>
    </div>
    <!-- end header -->
    </div>
    <!-- start page -->
    <div id="page">
    <!-- start content -->
    <div id="content">
    <div class="post">
    <br>
    <form name="dcontrol" action="/cgi-bin/dcontrol" method="GET">
    <input type="hidden" name="NoData" value="1"/>
    <p><strong>Spiacenti Monitor spento     </strong></p>
    <input type="submit" value="Aggiorna"/>
    </form>
    </div>

        </div>
        &lt;!-- end content --&gt;
    
        <div style="clear: both;">&nbsp;</div>
    

    </div>
    <!-- end page -->
    <!-- start footer -->
    <div id="footer">

    </div>
    <!-- end footer -->
    </body>
    </html>

    @



  • Try changing the first line to

    @
    printf("Content-Type:text/html\r\n\r\n");
    @



  • I solved, the problem was boa webserver and cgi. In the cgi i have a printf before @ printf("Content-Type:text/html\n\n");@ In this boa behaviour is different from apache.



  • Hello,

    [quote author="nicola1" date="1293138310"]I solved, the problem was boa webserver and cgi. In the cgi i have a printf before @ printf("Content-Type:text/html\n\n");@ In this boa behaviour is different from apache.[/quote]

    As far I can go the problem is not a matter of Apache but the way the OS determine the string end.

    A few months ago I implemented my own version of the HttpRequestHeader parsing al the content to Hash POST and GET vars. Looking at the original implementation I could find a very interesting and simple OS strind end detector. Have a look to the source code:

    @void HttpRequestHeader::setOSCharEnd(QString request)
    {
    this->_osCharEnd = "\n";
    int pos = request.indexOf(QLatin1Char('\n'));

    if (pos > 0 && request.at(pos - 1) == QLatin1Char('\r'))
    {
     this->_osCharEnd  = "\r\n";
    }
    

    }@

    request is a raw http request sended by a browser to my server...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.