Exemplo n.º 1
0
void HttpClient::onRequest(Http::Client& client)
{
    try
    {
        Pt::Http::MessageProgress progress = client.endSend();
        if( ! progress.finished() )
        {
            client.beginSend(false);
            return;
        }

        while( ! advanceMessage() )
        {
            if(client.request().buffer().size() > 8192)
            {
                client.beginSend(false);
                return;
            }
        }
        
        finishMessage();

        client.beginReceive();
    }
    catch(const System::IOError&) // HttpError is also an IOError
    {
        // setError() makes finishResult() call onError() where we throw
        setError();
        finishResult();
    }
}
Exemplo n.º 2
0
void HttpClient::onReply(Http::Client& client)
{
    try
    {
        Http::MessageProgress progress = client.endReceive();

        if( progress.header() )
        {
            //_impl->verifyHeader( client.reply() );
            
            beginResult( client.reply().body() );
        }

        if( progress.body() )
        {
            // reads until error or XML was consumed
            parseResult();

            // discard remaining data
            client.reply().discard();
        }
        
        if( ! progress.finished() )
        { 
            client.beginReceive();
            return;
        }
    }
    catch(const System::IOError&) // HttpError is also an IOError
    {
        // finished signal will call onError()
        setError();
        finishResult();
        return;
    }

    // send finished signal
    finishResult();
}