Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Skylark » Http::Finalize adds Content-Type even when it is empty
Http::Finalize adds Content-Type even when it is empty [message #59120] Sun, 06 November 2022 11:49 Go to previous message
Zbych is currently offline  Zbych
Messages: 325
Registered: July 2009
Senior Member
Hi,

Http::Finalize in Skylark shouldn't add Content-Type header when content_type is empty.

void Http::Finalize()
{
    if(rsocket) {
        SKYLARKLOG("=== Response: " << code << ' ' << code_text);
        String r;

        // weird apache2 mod_scgi behaviour
        if(hdr.scgi)
            r << "Status: ";
        else
            r << "HTTP/1.1 ";

        if(redirect.GetCount()) {
            // for SCGI (at least on apache 2 mod_scgi), we need protocol inside url
            if(hdr.scgi && redirect.Find(":") < 0)
                redirect = "http:" + redirect;

            SKYLARKLOG("Redirect to: " << redirect);
            r << code << " Found\r\n";
            r << "Location: " << redirect << "\r\n";
            for(int i = 0; i < cookies.GetCount(); i++)
                r << cookies[i];
        }
        else {
            r <<
                code << ' ' << code_text << "\r\n" 
                "Date: " <<  WwwFormat(GetUtcTime()) << "\r\n" 
                "Content-Length: " << response.GetCount() << "\r\n" 
                << (content_type.GetLength() ? ("Content-Type: " << content_type << "\r\n") : ""); //<------------ FIX
            for(int i = 0; i < headers.GetCount(); i++)
                r << headers.GetKey(i) << ": " << headers[i] << "\r\n";
            for(int i = 0; i < cookies.GetCount(); i++)
                r << cookies[i];
        }
        r << "\r\n";
        rsocket->PutAll(r);
        rsocket->PutAll(response);
        rsocket = NULL;
    }
}

 
Read Message
Read Message
Read Message
Previous Topic: light for Skylark
Next Topic: Changelog Skylark 24/10/2023
Goto Forum:
  


Current Time: Fri Apr 19 18:10:01 CEST 2024

Total time taken to generate the page: 0.03888 seconds