• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ send_headers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中send_headers函数的典型用法代码示例。如果您正苦于以下问题:C++ send_headers函数的具体用法?C++ send_headers怎么用?C++ send_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: PT_THREAD

/*
 =======================================================================================================================
 =======================================================================================================================
 */
static PT_THREAD(handle_output (struct httpd_state *s))
{
	/*~~~~~~~~~*/
	char	*ptr;
	/*~~~~~~~~~*/

	PT_BEGIN(&s->outputpt);

	if(!httpd_fs_open(s->filename, &s->file))
	{
		httpd_fs_open(http_404_html, &s->file);
		strcpy(s->filename, http_404_html);
		PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_404));
		PT_WAIT_THREAD(&s->outputpt, send_file(s));
	}
	else
	{
		PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
		ptr = strchr(s->filename, ISO_period);
		if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0)
		{
			vProcessInput( s->filename );
			PT_INIT(&s->scriptpt);
			PT_WAIT_THREAD(&s->outputpt, handle_script(s));
		}
		else
		{
			PT_WAIT_THREAD(&s->outputpt, send_file(s));
		}
	}

	PSOCK_CLOSE(&s->sout);
	PT_END(&s->outputpt);
}
开发者ID:Hermis,项目名称:FreeRTOS_OR1200,代码行数:38,代码来源:httpd.c


示例2: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->outputpt);
 
  if(!httpd_fs_open(s->filename, &s->file)) {
    strcpy(s->filename, ip64_webserver_http_404_html);
    httpd_fs_open(s->filename, &s->file);
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   ip64_webserver_http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   ip64_webserver_http_header_200));
    ptr = strrchr(s->filename, ISO_period);
    if(ptr != NULL && strncmp(ptr, ip64_webserver_http_shtml, 6) == 0) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt,
		     send_file(s));
    }
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:ADVANSEE,项目名称:mist,代码行数:32,代码来源:httpd.c


示例3: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

  petsciiconv_topetscii(s->filename, sizeof(s->filename));
  s->fd = cfs_open(s->filename, CFS_READ);
  petsciiconv_toascii(s->filename, sizeof(s->filename));
  if(s->fd < 0) {
    strcpy(s->filename, "notfound.html");
    s->fd = cfs_open(s->filename, CFS_READ);
    petsciiconv_toascii(s->filename, sizeof(s->filename));
    if(s->fd < 0) {
      PT_WAIT_THREAD(&s->outputpt,
                     send_headers(s, http_header_404));
      PT_WAIT_THREAD(&s->outputpt,
                     send_string(s, "not found"));
      uip_close();
      webserver_log_file(&uip_conn->ripaddr, "404 (no notfound.html)");
      PT_EXIT(&s->outputpt);
    }
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, http_header_404));
    webserver_log_file(&uip_conn->ripaddr, "404 - notfound.html");
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, http_header_200));
  }
  PT_WAIT_THREAD(&s->outputpt, send_file(s));
  cfs_close(s->fd);
  s->fd = -1;
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:arbraham,项目名称:hummingbird,代码行数:35,代码来源:httpd-cfs.c


示例4: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

  s->fd = cfs_open(s->filename, CFS_READ);
  if(s->fd < 0) {
    s->fd = cfs_open("404.html", CFS_READ);
    if(s->fd < 0) {
      uip_abort();
      PT_EXIT(&s->outputpt);
    }
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, "HTTP/1.0 404 Not found\r\n"));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s, "HTTP/1.0 200 OK\r\n"));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
    cfs_close(s->fd);
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:27,代码来源:httpd-cfs.c


示例5: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->outputpt);
 
  if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_fs_open(http_404_html, &s->file);
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt,
		   send_headers(s,
		   http_header_200));
    ptr = strchr(s->filename, ISO_period);
#if HTTPD_CONF_SCRIPT
    if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt,
		     send_file(s));
    }
#else /* HTTPD_CONF_SCRIPT */
    PT_WAIT_THREAD(&s->outputpt,
		   send_file(s));
#endif /* HTTPD_CONF_SCRIPT */
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:36,代码来源:httpd.c


示例6: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);
  s->script = httpd_cgi(&s->filename[1]);
  if(!s->script) {
    httpd_cgi_command_t *cmd = httpd_cgi_command(&s->filename[1]);
    if(cmd) {
      s->script = cmd->function(s);
    }
  }
  if(s->script) {
    if((s->script->flags & HTTPD_CUSTOM_HEADER) == 0) {
      PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
    }
    if((s->script->flags & HTTPD_CUSTOM_TOP) == 0) {
      PT_WAIT_THREAD(&s->outputpt, generate_top(s));
    }
    PT_WAIT_THREAD(&s->outputpt, s->script->function(s));
    if((s->script->flags & HTTPD_CUSTOM_BOTTOM) == 0) {
      PT_WAIT_THREAD(&s->outputpt, generate_bottom(s));
    }
#if CONTIKI_TARGET_NATIVE
  } else if (httpd_is_file(s->filename)){
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
    PT_WAIT_THREAD(&s->outputpt, send_file(s));
#endif
  } else {
    LOG6LBR_6ADDR(WARN, &uip_conn->ripaddr, "File '%s' not found, from ", s->filename);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt, generate_404(s));
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:35,代码来源:httpd.c


示例7: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);
 
  char *ptr;

  if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_fs_open(http_404_html, &s->file);
    strcpy_P(s->filename, http_404_html);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt, send_file(s));
  } else {
    snprintf(s->tmp_str, sizeof(s->tmp_str) -1, "%d", s->file.len);
    //snprintf(s->str_tmp, 8, "%d", s->len);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, http_header_200));
    ptr = strchr(s->filename, ISO_period);
    if(ptr != NULL && strncmp_P(ptr, http_shtml, 6) == 0) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt, send_file(s));
    }
  }

  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:jaseg,项目名称:avr-uip,代码行数:29,代码来源:httpd.c


示例8: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

  s->script = NULL;
  s->script = httpd_simple_get_script(&s->filename[1]);
  if(s->script == NULL) {
    strncpy(s->filename, "/notfound.html", sizeof(s->filename));
    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
                   send_string(s, NOT_FOUND));
    uip_close();
    webserver_log_file(&uip_conn->ripaddr, "404 - not found");
    PT_EXIT(&s->outputpt);
  } else {
    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_200));
    PT_WAIT_THREAD(&s->outputpt, s->script(s));
  }
  s->script = NULL;
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:AWRyder,项目名称:contiki,代码行数:25,代码来源:httpd-simple.c


示例9: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  char *ptr;
  
  PT_BEGIN(&s->outputpt);
#if DEBUGLOGIC
   httpd_strcpy(s->filename,httpd_indexfn);
#endif
  if(!httpd_fs_open(s->filename, &s->file)) {
    httpd_strcpy(s->filename, httpd_404fn);
    httpd_fs_open(s->filename, &s->file);
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_404notf));
    PT_WAIT_THREAD(&s->outputpt, send_file(s));
  } else {
    PT_WAIT_THREAD(&s->outputpt, send_headers(s, httpd_200ok));
    ptr = strchr(s->filename, ISO_period);
    if((ptr != NULL && httpd_strncmp(ptr, httpd_shtml, 6) == 0) || httpd_strcmp(s->filename,httpd_indexfn)==0) {
      PT_INIT(&s->scriptpt);
      PT_WAIT_THREAD(&s->outputpt, handle_script(s));
    } else {
      PT_WAIT_THREAD(&s->outputpt, send_file(s));
    }
  }
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
开发者ID:Ammar-85,项目名称:contiki-arduino,代码行数:27,代码来源:httpd.c


示例10: PT_THREAD

/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
	char *ptr;		  
	PT_BEGIN(&s->outputpt);		  
	if(!httpd_fs_open(s->filename,&s->file))//打开HTML文件不成功 
	{
		httpd_fs_open(http_404_html, &s->file);
		strcpy(s->filename, http_404_html);
		PT_WAIT_THREAD(&s->outputpt,
		send_headers(s,http_header_404));	//发送404失败页面
		PT_WAIT_THREAD(&s->outputpt,send_file(s));
	}else //打开HTML文件成功
	{
		PT_WAIT_THREAD(&s->outputpt,send_headers(s,http_header_200));
		ptr=strchr(s->filename, ISO_period);
		if(ptr != NULL && strncmp(ptr,http_shtml,6) == 0)//判断文件后缀是否为.SHTML 
		{
			PT_INIT(&s->scriptpt);
			PT_WAIT_THREAD(&s->outputpt, handle_script(s));
		}else
		{
			PT_WAIT_THREAD(&s->outputpt,send_file(s));
		}
	}
	PSOCK_CLOSE(&s->sout);
	PT_END(&s->outputpt);
}
开发者ID:rajutieto,项目名称:Magnetomometer,代码行数:29,代码来源:httpd.c


示例11: PT_THREAD

static
PT_THREAD(handle_output(struct httpd_state *s))
{
  PT_BEGIN(&s->outputpt);

#if DEBUGLOGIC
   strcpy_P(s->filename,PSTR("/x"));
#endif
#if FIND_THE_SCRIPT
  s->script = httpd_simple_get_script(&s->filename[1]);
  if(s->script == NULL) {
    printf_P(PSTR("not found!"));
    strcpy_P(s->filename, PSTR("/notfound.html"));

    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_404));
    PT_WAIT_THREAD(&s->outputpt,
                   send_string_P(s, NOT_FOUND));
    uip_close();

    PT_EXIT(&s->outputpt);
  } else {
#else
  s->script = generate_routes;
  if (1) {
#endif

    PT_WAIT_THREAD(&s->outputpt,
                   send_headers(s, http_header_200));
    PT_WAIT_THREAD(&s->outputpt, s->script(s));
  }
  s->script = NULL;
  PSOCK_CLOSE(&s->sout);
  PT_END(&s->outputpt);
}
/*---------------------------------------------------------------------------*/
static void
handle_connection(struct httpd_state *s)
{
#if DEBUGLOGIC
  handle_output(s);
#else
  handle_input(s);
  if(s->state == STATE_OUTPUT) {
    handle_output(s);
  }
#endif
}
开发者ID:Cancan79,项目名称:mist,代码行数:48,代码来源:httpd-simple-avr.c


示例12: send_request

int
send_request(Request req)
{
	if (! req->socket ) {
		req->socket = connect_socket(req->host,req->port,0);
		if (! req->socket) {
			error("Failed to connect to %s:%i\n",req->host,req->port);
			return 0;
		}
		add_req_socket(req->socket->fd);
		return 0;
	}
	if (req->length < 0) {
		str cmd = _("%s %s HTTP/1.1\r\n",req->method,req->path);
		write_socket(req->socket,cmd);
		request_headers(req,_("Host"),req->host);
		send_headers(req->socket,req->headers);
		req->length = outbound_content_length(req->contents,req->raw_contents);	
		return req->contents != NULL || req->raw_contents != NULL ;
	}
	req->written += req->contents ?
			send_contents(req->socket,req->contents,is_chunked(req->headers)) :
		req->raw_contents ?
			send_raw_contents(req->socket,req->raw_contents,req->written,0):
			0;
	if (is_chunked(req->headers) && req->written >= req->length)
		write_chunk(req->socket,NULL,0);
	return req->written < req->length;
}
开发者ID:cthulhuology,项目名称:Jawas,代码行数:29,代码来源:requests.c


示例13: handle_request

static int handle_request(struct mg_connection *conn)
{
	static const char *PONG_STR =
		"{\"version\" : \"brubeck %s\", \"pid\" : %d, \"status\" : \"%s\"}\n";

	if (!strcmp(conn->request_method, "GET")) {
		if (!strcmp(conn->uri, "/ping")) {
			struct brubeck_server *brubeck = conn->server_param;
			const char *status = "OK";

			if (brubeck->at_capacity)
				status = "CAPACITY";
			if (!brubeck->running)
				status = "SHUTDOWN";

			send_headers(conn);
			mg_printf_data(conn, PONG_STR, GIT_SHA, getpid(), status);
			return MG_TRUE;
		}

		if (!strcmp(conn->uri, "/stats"))
			return send_stats(conn);

		if (starts_with(conn->uri, "/metric/"))
			return send_metric(conn);
	}

	if (!strcmp(conn->request_method, "POST")) {
		if (starts_with(conn->uri, "/expire/"))
			return expire_metric(conn);
	}

	return MG_FALSE;
}
开发者ID:evelynmitchell,项目名称:brubeck,代码行数:34,代码来源:http.c


示例14: filehead

void filehead(FILE *f, char *path, struct stat *statbuf)

{

  char data[4096];

  int n;


  FILE *file = fopen(path, "r");

  if (!file)

    send_error(f, 403, "Forbidden", NULL, "Access denied.");

  else

    {

      int length = S_ISREG(statbuf->st_mode) ? statbuf->st_size : -1;

      send_headers(f, 200, "OK", NULL, get_mime_type(path), length, statbuf->st_mtime);


      fclose(file);

    }

}
开发者ID:dcampbell01,项目名称:httpSer,代码行数:29,代码来源:example.c


示例15: reject_req

static void reject_req(struct mg_connection *conn, int result) {
    char resp[500];
    send_headers(conn);

    // Return a please go away message
    snprintf(resp, sizeof(resp), ((strstr(conn->uri, "://") == NULL)?
                    "<html><head><meta name='google-site-verification' content='sdVLgoSVNvwkjzJEwKUVFlbBuQY-n2HBoUzlHPBWGN8' /><title>Page not found</title></head><body><p>This page you requested '%s' does not exist</p></body></html>"
               :    "<html><head><meta name='google-site-verification' content='sdVLgoSVNvwkjzJEwKUVFlbBuQY-n2HBoUzlHPBWGN8' /><title>This is not a proxy</title></head><body><p>This is not an open proxy. Your IP address %s has been banned</p></body></html>"), conn->remote_ip);

    // Handle invalid method
    if (result == 501)
       snprintf(resp, sizeof(resp), "<html><head><title>No Supported</title></head><body><h1>501 Not Supported</h1><p>Method '%s' is not supported by this server</p></body></html>", conn->request_method);

    // Send result
    mg_send_status(conn, result);

    // Compute a message len and return a Content-Length header
    char lenStr[10];
    mg_send_header(conn, "Content-Language", "en");
    int len = strlen(resp);
    snprintf(lenStr, 10, "%d", len);
    mg_send_header(conn, "Content-Length", lenStr);

    // Return the rejection message
    mg_printf_data(conn, resp, conn->uri);
}
开发者ID:Papafox,项目名称:checkip,代码行数:26,代码来源:checkip.c


示例16: handle_health

static int handle_health(struct mg_connection *conn)
{
    send_headers(conn);
    char health[4] = {(char)0xF0, (char)0x9F, (char)0x91, (char)0xBB};
    mg_send_data(conn, health, 4);
    return MG_TRUE;
}
开发者ID:jpalladino84,项目名称:ichabod,代码行数:7,代码来源:main.cpp


示例17: send_error

// format of error to be displayed
void send_error(FILE *f, char *path, int status, char *title, char *extra, char *text) {
	send_headers(f, path, status, title, extra, "text/html", -1, -1);
	fprintf(f, "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>\r\n", status, title);
	fprintf(f, "<BODY><H4>%d %s</H4>\r\n", status, title);
	fprintf(f, "%s\r\n", text);
	fprintf(f, "</BODY></HTML>\r\n");
}
开发者ID:yeanlingyawner,项目名称:webServer,代码行数:8,代码来源:teamServerCGITested2.c


示例18: checkip_robots

static void checkip_robots(struct mg_connection *conn) {
    const char* remote_ip = conn->remote_ip;
    send_headers(conn);
    mg_printf_data(conn, robots);
    updateRobot();
    log_msg(daemon_mode, "robots.txt sent to %s", remote_ip);
}
开发者ID:Papafox,项目名称:checkip,代码行数:7,代码来源:checkip.c


示例19: finalostream_send

void finalostream_send(h2o_ostream_t *self, h2o_req_t *req, h2o_iovec_t *bufs, size_t bufcnt, int is_final)
{
    h2o_http2_stream_t *stream = H2O_STRUCT_FROM_MEMBER(h2o_http2_stream_t, _ostr_final, self);
    h2o_http2_conn_t *conn = (h2o_http2_conn_t*)req->conn;

    assert(stream->_data.size == 0);

    /* send headers */
    switch (stream->state) {
    case H2O_HTTP2_STREAM_STATE_SEND_HEADERS:
        send_headers(conn, stream);
        /* fallthru */
    case H2O_HTTP2_STREAM_STATE_SEND_BODY:
        if (is_final)
            stream->state = H2O_HTTP2_STREAM_STATE_END_STREAM;
        break;
    case H2O_HTTP2_STREAM_STATE_END_STREAM:
        /* might get set by h2o_http2_stream_reset */
        return;
    default:
        assert(!"cannot be in a receiving state");
    }

    /* save the contents in queue */
    if (bufcnt != 0) {
        h2o_vector_reserve(&req->pool, (h2o_vector_t*)&stream->_data, sizeof(h2o_iovec_t), bufcnt);
        memcpy(stream->_data.entries, bufs, sizeof(h2o_iovec_t) * bufcnt);
        stream->_data.size = bufcnt;
    }

    h2o_http2_conn_register_for_proceed_callback(conn, stream);
}
开发者ID:bowlofstew,项目名称:h2o,代码行数:32,代码来源:stream.c


示例20: send_remaining_packets

static bool send_remaining_packets(struct rtmp_stream *stream)
{
	struct encoder_packet packet;
	uint64_t max_ns = (uint64_t)stream->max_shutdown_time_sec * 1000000000;
	uint64_t begin_time_ns = os_gettime_ns();

	if (!stream->sent_headers) {
		if (!send_headers(stream))
			return false;
	}

	while (get_next_packet(stream, &packet)) {
		if (send_packet(stream, &packet, false, packet.track_idx) < 0)
			return false;

		/* Just disconnect if it takes too long to shut down */
		if ((os_gettime_ns() - begin_time_ns) > max_ns) {
			info("Took longer than %d second(s) to shut down, "
			     "automatically stopping connection",
			     stream->max_shutdown_time_sec);
			return false;
		}
	}

	return true;
}
开发者ID:Birdboat,项目名称:obs-studio,代码行数:26,代码来源:rtmp-stream.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ send_instruction函数代码示例发布时间:2022-05-30
下一篇:
C++ send_header函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap