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 next message
Zbych is currently offline  Zbych
Messages: 327
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;
    }
}

Re: Http::Finalize adds Content-Type even when it is empty [message #59121 is a reply to message #59120] Sun, 06 November 2022 20:13 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1087
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Zbych,

Please create PR for Skylar repo with proposed changed. It seems that Mirek doesn't actively develop Skylark anymore and it would be good if somebody will take it from him. So, even if the fix is correct, it might not be applied. Also, having PR in place it is unlikely that the change will not be addressed. With the forum post it might happened.

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 06 November 2022 20:14]

Report message to a moderator

Re: Http::Finalize adds Content-Type even when it is empty [message #60232 is a reply to message #59120] Tue, 24 October 2023 16:09 Go to previous message
Xemuth is currently offline  Xemuth
Messages: 387
Registered: August 2018
Location: France
Senior Member
Hello there,

Mirek gave me right to update Skylark. I will now update it.

Thanks for your FIX Zbych. I will take it into account.

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


Current Time: Sat Dec 14 15:18:07 CET 2024

Total time taken to generate the page: 0.04199 seconds