当前位置: 首页>>代码示例>>C++>>正文


C++ Reply::addHeader方法代码示例

本文整理汇总了C++中cxxtools::http::Reply::addHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ Reply::addHeader方法的具体用法?C++ Reply::addHeader怎么用?C++ Reply::addHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cxxtools::http::Reply的用法示例。


在下文中一共展示了Reply::addHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: showCutterStatus

void RecordingsResponder::showCutterStatus(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/recordings/cut", request);
  StreamExtension s(&out);

  bool active = cCutter::Active();

  if (q.isFormat(".html")) {
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
     s.writeHtmlHeader("HtmlCutterStatus");
     s.write((active ? "True" : "False"));
     s.write("</body></html>");
  } else if (q.isFormat(".json")) {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     cxxtools::JsonSerializer serializer(out);
     serializer.serialize(active, "active");
     serializer.finish();     
  } else if (q.isFormat(".xml")) {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     s.write("<cutter xmlns=\"http://www.domain.org/restfulapi/2011/cutter-xml\">\n");
     s.write(cString::sprintf(" <param name=\"active\">%s</param>\n", (active ? "true" : "false")));
     s.write("</cutter>");
  } else {
     reply.httpReturn(502, "Only the following formats are supported: .xml, .json and .html");
  } 
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:26,代码来源:recordings.cpp

示例2: reply

void OsdResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/osd", request);

  if ( request.method() != "GET" ) {
     reply.httpReturn(403, "Only GET-method is supported!");
     return;
  }

  BasicOsd* osd = StatusMonitor::get()->getOsd();

  if ( osd == NULL ) {
     if ( q.isFormat(".html") ) {
        reply.addHeader("Content-Type", "text /html; charset=utf-8");
        printEmptyHtml(out);
        return;
     } else {
        reply.httpReturn(404, "No OSD opened!");
        return;
     }
  }

  string format = "";
  if ( q.isFormat(".json") ) {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     format = ".json";
  } else if ( q.isFormat(".html") ) {
     format = ".html";
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
  } else if ( q.isFormat(".xml") ) {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     format = ".xml";
  } else {
     reply.httpReturn(403, "Resources are not available for the selected format. (Use: .json, .html or .xml)");
     return;
  }

  int start_filter = q.getOptionAsInt("start");
  int limit_filter = q.getOptionAsInt("limit");

  switch(osd->Type())
  {
     case 0x01: printTextOsd(out, (TextOsd*)osd, format, start_filter, limit_filter);
                break;
     case 0x02: { ChannelOsdWrapper* w = new ChannelOsdWrapper(&out);
                  w->print((ChannelOsd*)osd, format);
                  delete w; }
                break;
     case 0x03: { ProgrammeOsdWrapper* w = new ProgrammeOsdWrapper(&out);
                  w->print((ProgrammeOsd*)osd, format);
                  delete w; }
                break;
  }
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:54,代码来源:osd.cpp

示例3: cutRecording

void RecordingsResponder::cutRecording(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/recordings/cut", request);
  const cRecording* recording = getRecordingByRequest(q);

  if ( recording != NULL ) {
#if APIVERSNUM > 20101
     if (RecordingsHandler.GetUsage(recording->FileName()) != ruNone) {
#else
     if (cCutter::Active()) {
#endif
        reply.httpReturn(504, "VDR Cutter currently busy.");
     } else {
#if APIVERSNUM > 20101
        RecordingsHandler.Add(ruCut, recording->FileName());
#else
        cCutter::Start(recording->FileName());
#endif
     }
     return;
  }
  reply.httpReturn(503, "Cutting recordings failed.");
}

void RecordingsResponder::showCutterStatus(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
	QueryHandler q("/recordings/cut", request);
	StreamExtension s(&out);

	#if APIVERSNUM > 20101
	bool active = RecordingsHandler.Active();
	#else
	bool active = cCutter::Active();
	#endif

	if (q.isFormat(".html")) {
		reply.addHeader("Content-Type", "text/html; charset=utf-8");
		s.writeHtmlHeader("HtmlCutterStatus");
		s.write((active ? "True" : "False"));
		s.write("</body></html>");
	} else if (q.isFormat(".json")) {
		reply.addHeader("Content-Type", "application/json; charset=utf-8");
		cxxtools::JsonSerializer serializer(out);
		serializer.serialize(active, "active");
		serializer.finish();
	} else if (q.isFormat(".xml")) {
		reply.addHeader("Content-Type", "text/xml; charset=utf-8");
		s.write("<cutter xmlns=\"http://www.domain.org/restfulapi/2011/cutter-xml\">\n");
		s.write(cString::sprintf(" <param name=\"active\">%s</param>\n", (active ? "true" : "false")));
		s.write("</cutter>");
	} else {
		reply.httpReturn(502, "Only the following formats are supported: .xml, .json and .html");
	}
}
开发者ID:yavdr,项目名称:vdr-plugin-restfulapi,代码行数:54,代码来源:recordings.cpp

示例4: reply

void RemoteResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler::addHeader(reply);

  if ( request.method() == "OPTIONS" ) {
      reply.addHeader("Allow", "POST");
      reply.httpReturn(200, "OK");
      return;
  }

  if (request.method() != "POST") {
     reply.httpReturn(403, "Only POST method is support by the remote control");
     return;
  }

  if ( (int)request.url().find("/remote/switch") != -1 ) {
     QueryHandler q("/remote/switch", request);
     const cChannel* channel = VdrExtension::getChannel(q.getParamAsString(0));
     if ( channel == NULL ) {
        reply.httpReturn(404, "Channel-Id is not valid.");
     } else {
        TaskScheduler::get()->SwitchableChannel(channel->GetChannelID());
     }

     return;
  } 

  if (!keyPairList->hitKey(request, reply)) {
     reply.httpReturn(404, "Remote Control does not support the requested key.");
  }
}
开发者ID:hannemann,项目名称:vdr-plugin-restfulapi,代码行数:31,代码来源:remote.cpp

示例5: replyImage

void ChannelsResponder::replyImage(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  StreamExtension se(&out);
  QueryHandler q("/channels/image/", request);
  
  std::string channelid = q.getParamAsString(0);
  cChannel* channel = VdrExtension::getChannel(channelid);
  std::string imageFolder = Settings::get()->ChannelLogoDirectory() + (std::string)"/";
  
  if (channel == NULL) {
     reply.httpReturn(502, "Channel not found!");
     return;
  }

  std::string imageName = FileCaches::get()->searchChannelLogo(channel);

  if (imageName.length() == 0 ) {
     reply.httpReturn(502, "No image found!");
     return;
  }
  
  std::string absolute_path = imageFolder + imageName;
  std::string contenttype = (std::string)"image/" + imageName.substr( imageName.find_last_of('.') + 1 );
  if ( se.writeBinary(absolute_path) ) {
     reply.addHeader("Content-Type", contenttype.c_str());
  } else {
    reply.httpReturn(502, "Binary Output failed");
  }
}
开发者ID:sja,项目名称:vdr-plugin-restfulapi,代码行数:29,代码来源:channels.cpp

示例6: showTimers

void TimersResponder::showTimers(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/timers", request);
  TimerList* timerList;
 
  Timers.SetModified();

  if ( q.isFormat(".json") ) {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     timerList = (TimerList*)new JsonTimerList(&out);
  } else if ( q.isFormat(".html") ) {
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
     timerList = (TimerList*)new HtmlTimerList(&out);
  } else if ( q.isFormat(".xml") ) {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     timerList = (TimerList*)new XmlTimerList(&out);
  } else {
     reply.httpReturn(404, "Resources are not available for the selected format. (Use: .json, .html or .xml)");
     return;
  }

  int start_filter = q.getOptionAsInt("start");
  int limit_filter = q.getOptionAsInt("limit");

  string timer_id = q.getParamAsString(0);

  if ( start_filter >= 0 && limit_filter >= 1 ) {
     timerList->activateLimit(start_filter, limit_filter);
  }

  timerList->init();

  vector< cTimer* > timers = VdrExtension::SortedTimers();
  for (int i=0;i<(int)timers.size();i++)
  {
     if ( VdrExtension::getTimerID(timers[i]) == timer_id || timer_id.length() == 0 ) {
        timerList->addTimer(timers[i]);   
     }
  }
  timerList->setTotal((int)timers.size());

  timerList->finish();
  delete timerList;   
}
开发者ID:illyah,项目名称:vdr-plugin-restfulapi,代码行数:44,代码来源:timers.cpp

示例7: showRecordings

void RecordingsResponder::showRecordings(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/recordings", request);
  RecordingList* recordingList;
  bool read_marks = q.getOptionAsString("marks") == "true";

  if ( q.isFormat(".json") ) {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     recordingList = (RecordingList*)new JsonRecordingList(&out, read_marks);
  } else if ( q.isFormat(".html") ) {
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
     recordingList = (RecordingList*)new HtmlRecordingList(&out, read_marks);
  } else if ( q.isFormat(".xml") )  {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     recordingList = (RecordingList*)new XmlRecordingList(&out, read_marks);
  } else {
     reply.httpReturn(404, "Resources are not available for the selected format. (Use: .json or .html)");
     return;
  }

  int start_filter = q.getOptionAsInt("start");
  int limit_filter = q.getOptionAsInt("limit");
  
  int requested_item = q.getParamAsInt(0);

  if ( start_filter >= 0 && limit_filter >= 1 ) {
     recordingList->activateLimit(start_filter, limit_filter);
  }

  recordingList->init();
  
  cRecording* recording = NULL;
  for (int i = 0; i < Recordings.Count();i++) {
     if ( requested_item == i || requested_item < 0 ) {
        recording = Recordings.Get(i);
        recordingList->addRecording(recording, i); 
     }
  }
  recordingList->setTotal(Recordings.Count());

  recordingList->finish();
  delete recordingList;
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:43,代码来源:recordings.cpp

示例8: replySearch

void SearchTimersResponder::replySearch(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/searchtimers/search", request);
  vdrlive::SearchResults searchResults;
  int id = q.getParamAsInt(0);

  EventList* eventList;

  if ( q.isFormat(".json") ) {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     eventList = (EventList*)new JsonEventList(&out);
  } else if ( q.isFormat(".html") ) {
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
     eventList = (EventList*)new HtmlEventList(&out);
  } else if ( q.isFormat(".xml") ) {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     eventList = (EventList*)new XmlEventList(&out);
  } else {
     reply.httpReturn(403, "Resources are not available for the selected format. (Use: .json, .xml or .html)");
     return;
  }
  
  searchResults.GetByID(id);

  int start_filter = q.getOptionAsInt("start");
  int limit_filter = q.getOptionAsInt("limit");
  if ( start_filter >= 0 && limit_filter >= 1 )
     eventList->activateLimit(start_filter, limit_filter);
  
  eventList->init();
  int total = 0;
  
  for (vdrlive::SearchResults::iterator item = searchResults.begin(); item != searchResults.end(); ++item) {
    eventList->addEvent((cEvent*)item->GetEvent());
    total++;
  }

  eventList->setTotal(total);
  eventList->finish();
  delete eventList;
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:41,代码来源:searchtimers.cpp

示例9: replyGroups

void ChannelsResponder::replyGroups(std::ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{ 
  QueryHandler q("/channels/groups", request);
  ChannelGroupList* channelGroupList;
  
  if ( q.isFormat(".json") ) {
    reply.addHeader("Content-Type", "application/json; charset=utf-8");
    channelGroupList = (ChannelGroupList*)new JsonChannelGroupList(&out);
  } else if ( q.isFormat(".html") ) {
    reply.addHeader("Content-Type", "text/html; charset=utf-8");
    channelGroupList = (ChannelGroupList*)new HtmlChannelGroupList(&out);
  } else if ( q.isFormat(".xml") ) {
    reply.addHeader("Content-Type", "text/xml; charset=utf-8");
    channelGroupList = (ChannelGroupList*)new XmlChannelGroupList(&out);
  } else {
    reply.httpReturn(403, "Resources are not available for the selected format. (Use: .json, .html or .xml)");
    return;
  }

  int start_filter = q.getOptionAsInt("start");
  int limit_filter = q.getOptionAsInt("limit");
  if ( start_filter >= 0 && limit_filter >= 1 ) {
     channelGroupList->activateLimit(start_filter, limit_filter);
  }

  channelGroupList->init();
  int total = 0;
  
  for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel))
  {
      if (channel->GroupSep()) {
         channelGroupList->addGroup((std::string)channel->Name());
         total++;
      }
  }

  channelGroupList->setTotal(total);
  channelGroupList->finish();

  delete channelGroupList;
}
开发者ID:sja,项目名称:vdr-plugin-restfulapi,代码行数:41,代码来源:channels.cpp

示例10: replyShow

void SearchTimersResponder::replyShow(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/searchtimers", request);
  vdrlive::SearchTimers service;
  SearchTimerList* stList;

  if (q.isFormat(".json")) {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     stList = (SearchTimerList*)new JsonSearchTimerList(&out);
  } else if ( q.isFormat(".html")) {
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
     stList = (SearchTimerList*)new HtmlSearchTimerList(&out);
  } else if ( q.isFormat(".xml")) {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     stList = (SearchTimerList*)new XmlSearchTimerList(&out);
  } else {
     reply.httpReturn(405, "Resources are not available for the selected format. (Use: .json, .html or .xml)");
     return;
  }

  int start_filter = q.getOptionAsInt("start");
  int limit_filter = q.getOptionAsInt("limit");
  if ( start_filter >= 0 && limit_filter >= 1 ) stList->activateLimit(start_filter, limit_filter);

  stList->init();
  int counter = 0;

  for(vdrlive::SearchTimers::iterator timer = service.begin(); timer != service.end(); ++timer)
  { 
    SerSearchTimerContainer container;
    container.timer = &(*timer);
    stList->addSearchTimer(container);
    counter++;
  }

  stList->setTotal(counter);
  stList->finish();
  
  delete stList;
}
开发者ID:Saman-VDR,项目名称:vdr-plugin-restfulapi,代码行数:40,代码来源:searchtimers.cpp

示例11: replyCreatedId

void TimersResponder::replyCreatedId(cTimer* timer, cxxtools::http::Request& request, cxxtools::http::Reply& reply, ostream& out)
{
  QueryHandler q("/timers", request);
  TimerList* timerList;

  if ( q.isFormat(".html") ) {
     reply.addHeader("Content-Type", "text/html; charset=utf-8");
     timerList = (TimerList*)new HtmlTimerList(&out);
  } else if ( q.isFormat(".xml") ) {
     reply.addHeader("Content-Type", "text/xml; charset=utf-8");
     timerList = (TimerList*)new XmlTimerList(&out);
  } else {
     reply.addHeader("Content-Type", "application/json; charset=utf-8");
     timerList = (TimerList*)new JsonTimerList(&out);
  }

  timerList->init();
  timerList->addTimer(timer);
  timerList->setTotal(1);
  timerList->finish();
  delete timerList;
}
开发者ID:illyah,项目名称:vdr-plugin-restfulapi,代码行数:22,代码来源:timers.cpp

示例12: reply

void InfoResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler::addHeader(reply);
  QueryHandler q("/info", request);

  if (request.method() != "GET") {
     reply.httpReturn(403, "Only GET method is support by the remote control");
     return;
  }
  StreamExtension se(&out);

  if (q.isFormat(".xml")) {
    reply.addHeader("Content-Type", "text/xml; charset=utf-8");
    replyXml(se);
  } else if (q.isFormat(".json")) {
    reply.addHeader("Content-Type", "application/json; charset=utf-8");
    replyJson(se);
  } else if (q.isFormat(".html")) { 
    reply.addHeader("Content-Type", "text/html; charset=utf-8");
    replyHtml(se);
  }else {
    reply.httpReturn(403, "Support formats: xml, json and html!");
  }
}
开发者ID:MichaelE1000,项目名称:vdr-plugin-restfulapi,代码行数:24,代码来源:info.cpp

示例13: replyImage

void EventsResponder::replyImage(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler q("/events/image", request);
  if ( request.method() != "GET") {
     reply.httpReturn(403, "To retrieve information use the GET method!");
     return;
  }

  StreamExtension se(&out);
  int eventid = q.getParamAsInt(0);
  int number = q.getParamAsInt(1);
  double timediff = -1;
  
  vector< string > images;
  
  FileCaches::get()->searchEventImages(eventid, images);

  if (number < 0 || number >= (int)images.size()) {
     reply.httpReturn(404, "Could not find image because of invalid image number!");
     return;
  }

  string image = images[number];
  string type = image.substr(image.find_last_of(".")+1);
  string contenttype = (string)"image/" + type;
  string path = Settings::get()->EpgImageDirectory() + (string)"/" + image;

  if (request.hasHeader("If-Modified-Since")) {
      timediff = difftime(FileExtension::get()->getModifiedTime(path), FileExtension::get()->getModifiedSinceTime(request));
  }

  if (timediff > 0.0 || timediff < 0.0) {
    if ( se.writeBinary(path) ) {
       reply.addHeader("Content-Type", contenttype.c_str());
       FileExtension::get()->addModifiedHeader(path, reply);
    } else {
       reply.httpReturn(404, "Could not find image!");
    }
  } else {
      reply.httpReturn(304, "Not-Modified");
  }
}
开发者ID:hannemann,项目名称:vdr-plugin-restfulapi,代码行数:42,代码来源:events.cpp

示例14: reply

void EventsResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  if ( request.method() == "OPTIONS" ) {
      reply.addHeader("Allow", "GET, POST");
      reply.httpReturn(200, "OK");
      return;
  }

  QueryHandler::addHeader(reply);
  if ( (int)request.url().find("/events/image/") == 0 ) {
     replyImage(out, request, reply);
  } else if ( (int)request.url().find("/events/search") == 0 ){
     replySearchResult(out, request, reply);
  }

  else if ( (int)request.url().find("/events/contentdescriptors") == 0 ){
      replyContentDescriptors(out, request, reply);
  }

  else {
     replyEvents(out, request, reply);
  }
}
开发者ID:hannemann,项目名称:vdr-plugin-restfulapi,代码行数:23,代码来源:events.cpp

示例15: reply

void RecordingsResponder::reply(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
  QueryHandler::addHeader(reply);
  bool found = false;

  if (request.method() == "OPTIONS") {
     return;
  }

  if ((int)request.url().find("/recordings/play") == 0 ) {
     if ( request.method() == "GET" ) {
        playRecording(out, request, reply);
        reply.addHeader("Content-Type", "text/plain; charset=utf-8");
     } else if (request.method() == "POST") {
        rewindRecording(out, request, reply);
        reply.addHeader("Content-Type", "text/plain; charset=utf-8");
     } else {
        reply.httpReturn(501, "Only GET and POST method is supported by the /recordings/play service.");
     }
     found = true;
  }

  else if ((int)request.url().find("/recordings/cut") == 0 ) {
     if ( request.method() == "GET" ) {
        showCutterStatus(out, request, reply);
     } else if (request.method() == "POST") {
        cutRecording(out, request, reply); 
     } else {
        reply.httpReturn(501, "Only GET and POST methods are supported by the /recordings/cut service.");
     }
     found = true;
  }

  else if ((int)request.url().find("/recordings/marks") == 0 ) {
     if ( request.method() == "DELETE" ) {
        deleteMarks(out, request, reply);
     } else if (request.method() == "POST" ) {
        saveMarks(out, request, reply);
     } else {
        reply.httpReturn(501, "Only DELETE and POST methods are supported by the /recordings/marks service.");
     }
     found = true;
  }

  // original /recordings service
  else if ((int) request.url().find("/recordings") == 0 ) {
        if ( request.method() == "GET" ) {
        showRecordings(out, request, reply);
        found = true;
     } else if (request.method() == "DELETE" ) {
        deleteRecording(out, request,reply);
        found = true;
     } else {
        reply.httpReturn(501, "Only GET and DELETE methods are supported by the /recordings service.");
     }
     found = true;
  }

  if (!found) {
     reply.httpReturn(403, "Service not found");
  }
}
开发者ID:flensrocker,项目名称:vdr-plugin-restfulapi,代码行数:62,代码来源:recordings.cpp


注:本文中的cxxtools::http::Reply::addHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。