void HttpClientHandler::ChannelConnected(ChannelHandlerContext& ctx, ChannelStateEvent& e) { m_connected = true; m_client = ctx.GetChannel(); g_ready_channels.insert(this); try_send_request(); }
static void http_pipeline_init(ChannelPipeline* pipeline, void* data) { pipeline->AddLast("encoder", new HTTPMessageEncoder()); pipeline->AddLast("decoder", new HTTPMessageDecoder(false)); HttpClientHandler* handler = new HttpClientHandler; handler->m_client = (Channel*) data; pipeline->AddLast("handler", handler); g_all_channels.insert(handler); }
void HttpClientHandler::MessageReceived(ChannelHandlerContext& ctx, MessageEvent<HTTPMessage>& e) { g_recved_res++; g_ratio_recved_res++; m_request_sent = false; if (!g_options.keepAlive) { ctx.GetChannel()->Close(); g_all_channels.erase(this); } else { g_ready_channels.insert(this); } try_send_request(); }
void _validate(bool for_real) { // do we need to open a port? if ( m_server.isConnected()==false && !m_inError && m_legit ) changePort(m_port); if (m_stat.progress > 0) status(m_stat.progress, m_stat.ram, m_stat.p_ram, m_stat.time); // handle any connection error if ( m_inError ) error(m_connectionError.c_str()); // setup format etc info_.format(*m_fmtp.fullSizeFormat()); info_.full_size_format(*m_fmtp.format()); // add aovs as nuke channels std::string rgba = "RGBA"; std::string z = "Z"; std::string n = "N"; std::string p = "P"; for(std::vector<std::string>::iterator it = m_aovs.begin(); it != m_aovs.end(); ++it) { if (it->compare(rgba)==0) { if (!m_channels.contains(Chan_Red)) { m_channels.insert(Chan_Red); m_channels.insert(Chan_Green); m_channels.insert(Chan_Blue); m_channels.insert(Chan_Alpha); } } else if (it->compare(z)==0) { if (!m_channels.contains(Chan_Z)) m_channels.insert( Chan_Z ); } else if (it->compare(n)==0 || it->compare(p)==0) { if (!m_channels.contains(channel((boost::format("%s.X")%it->c_str()).str().c_str()))) { m_channels.insert( channel((boost::format("%s.X")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.Y")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.Z")%it->c_str()).str().c_str()) ); } } else { if (!m_channels.contains( channel((boost::format("%s.red")%it->c_str()).str().c_str()))) { m_channels.insert( channel((boost::format("%s.red")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.blue")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.green")%it->c_str()).str().c_str()) ); } } } info_.channels( m_channels ); info_.set(info().format()); }