I am developing a service http with libsoup, but I have a memory problem.
When you make a request, the service memory increases during transmission
and decreases only after the closure of the service. Another call and will
increase again.
The client is in another machine and the data may be very long (2 GB).
I try to user Soup.MemoryUse.TAKE but I get garbage data.
The Soup.Buffer is not free when sending a new buffer?

Thank you for suggestion.



public static int main(string[] args)
{
    Soup.Server server = new Soup.Server (Soup.SERVER_PORT, 12345);
    server.add_handler ("/data", default_handler);
    server.run();
    return 0;
}

void default_handler (Soup.Server server, Soup.Message msg, string path,
GLib.HashTable? query, Soup.ClientContext client) {

    r = new Reader();

    msg.response_headers.set_encoding(Soup.Encoding.EOF);
    msg.response_headers.append("Content-Type", "text/html" );
    msg.set_status(Soup.KnownStatusCode.OK);

    if (msg.method == "GET") {
        msg.wrote_headers.connect(write_next_chunk);
        msg.wrote_chunk.connect(write_next_chunk);
    }
}

public void write_next_chunk(Soup.Message msg){
        Soup.Buffer b = r.GetBuffer();
        msg.response_body.append_buffer (b);
}


Reader r;

public class Reader {

    public Soup.Buffer GetBuffer() {
        uint8[] b = {'a','b','c','d','e','f','g','h','i','l' };
        return new Soup.Buffer(Soup.MemoryUse.COPY, s.data);
    }
}
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to