//print information about a channel
ngx_int_t nchan_channel_info(ngx_http_request_t *r, ngx_uint_t messages, ngx_uint_t subscribers, time_t last_seen, nchan_msg_id_t *msgid) {
  ngx_buf_t                      *b;
  ngx_str_t                      *content_type;
  ngx_str_t                      *accept_header = NULL;
  
  if(r->headers_in.accept) {
    accept_header = &r->headers_in.accept->value;
  }
  
  b = nchan_channel_info_buf(accept_header, messages, subscribers, last_seen, msgid, &content_type);
  
  return nchan_respond_membuf(r, NGX_HTTP_OK, content_type, b, 0);
}
Exemplo n.º 2
0
//print information about a channel
static ngx_int_t nchan_channel_info(ngx_http_request_t *r, ngx_uint_t messages, ngx_uint_t subscribers, time_t last_seen) {
  ngx_buf_t                      *b;
  ngx_str_t                      *content_type;
  ngx_str_t                      *accept_header = NULL;
  
  if(r->headers_in.accept) {
    accept_header = &r->headers_in.accept->value;
  }
  
  b = nchan_channel_info_buf(accept_header, messages, subscribers, last_seen, &content_type);
  
  //not sure why this is needed, but content-type directly from the request can't be reliably used in the response 
  //(it probably can, but i'm just doing it wrong)
  /*if(content_type != &TEXT_PLAIN) {
    ERR("WTF why must i do this %p %V", content_type, content_type);
    content_type_copy.len = content_type->len;
    content_type_copy.data = ngx_palloc(r->pool, content_type_copy.len);
    assert(content_type_copy.data);
    ngx_memcpy(content_type_copy.data, content_type->data, content_type_copy.len);
    content_type = &content_type_copy;
  }*/
  
  return nchan_respond_membuf(r, NGX_HTTP_OK, content_type, b, 0);
}