tinyhttpd代码注释

2023-11-05

/* J. David's webserver */
/* This is a simple webserver.
 * Created November 1999 by J. David Blackstone.
 * CSE 4344 (Network concepts), Prof. Zeigler
 * University of Texas at Arlington
 */
/* This program compiles for Sparc Solaris 2.6.
 * To compile for Linux:
 *  1) Comment out the #include <pthread.h> line.
 *  2) Comment out the line that defines the variable newthread.
 *  3) Comment out the two lines that run pthread_create().
 *  4) Uncomment the line that runs accept_request().
 *  5) Remove -lsocket from the Makefile.
 */
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <ctype.h>
#include <strings.h>
#include <string.h>
#include <sys/stat.h>
#include <pthread.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <stdint.h>

#define ISspace(x) isspace((int)(x))

#define SERVER_STRING "Server: jdbhttpd/0.1.0\r\n"
#define STDIN   0
#define STDOUT  1
#define STDERR  2

void accept_request(void *);
void bad_request(int);
void cat(int, FILE *);
void cannot_execute(int);
void error_die(const char *);
void execute_cgi(int, const char *, const char *, const char *);
int get_line(int, char *, int);
void headers(int, const char *);
void not_found(int);
void serve_file(int, const char *);
int startup(u_short *);
void unimplemented(int);

/**********************************************************************/
/* A request has caused a call to accept() on the server port to
 * return.  Process the request appropriately.
 * Parameters: the socket connected to the client */
/**********************************************************************/
//解读所接受到的请求,并做处理
//客户端必须发送get 或 post请求头
//post和带参数的get url只能是cgi程序,不能是静态网页
//如果是文件夹,自动在末尾加上index.html
void accept_request(void *arg)
{
    int client = (intptr_t)arg;
    char buf[1024];
    size_t numchars;
    char method[255];
    char url[255];
    char path[512];
    size_t i, j;
    struct stat st;
    int cgi = 0;      /* becomes true if server decides this is a CGI
                       * program */
    char *query_string = NULL;

	//读取请求头
    numchars = get_line(client, buf, sizeof(buf));
    i = 0; j = 0;
	//复制在空格前的字符,i指向第一个空格
    while (!ISspace(buf[i]) && (i < sizeof(method) - 1))
    {
        method[i] = buf[i];
        i++;
    }
    j=i;
    method[i] = '\0';

	//判断请求是get还是post,如果都不是调用unimplemented
    if (strcasecmp(method, "GET") && strcasecmp(method, "POST"))
    {
        unimplemented(client);
        return;
    }

	//post方式的请求只能交给cgi程序处理
    if (strcasecmp(method, "POST") == 0)
        cgi = 1;

    i = 0;
	//跳过空格,j指向第二个字段
    while (ISspace(buf[j]) && (j < numchars))
        j++;
	//复制第2个字段到url
    while (!ISspace(buf[j]) && (i < sizeof(url) - 1) && (j < numchars))
    {
        url[i] = buf[j];
        i++; j++;
    }
    url[i] = '\0';

	//如果是get方法,截断url中?开始的字符串,query_string指向?后的第一个字符
	//如果是get方法,且请求行有'?',只能交给cgi程序处理
	//将url复制到query_string中
    if (strcasecmp(method, "GET") == 0)
    {
        query_string = url;
        while ((*query_string != '?') && (*query_string != '\0'))
            query_string++;
        if (*query_string == '?')
        {
            cgi = 1;
            *query_string = '\0';
            query_string++;
        }
    }

	//path = “htdocs”+url
    sprintf(path, "htdocs%s", url);
	//如果url中已经指明了是一个目录,path+"index.html"
    if (path[strlen(path) - 1] == '/')
        strcat(path, "index.html");
	//要访问的文件找不到
    if (stat(path, &st) == -1) {
		//丢弃HEADER部分
        while ((numchars > 0) && strcmp("\n", buf))  /* read & discard headers */
            numchars = get_line(client, buf, sizeof(buf));
        not_found(client);
    }
    else
    {
        if ((st.st_mode & S_IFMT) == S_IFDIR)
            strcat(path, "/index.html");
		//如果要找的文件是可执行程序,那么
        if ((st.st_mode & S_IXUSR) ||
                (st.st_mode & S_IXGRP) ||
                (st.st_mode & S_IXOTH)    )
            cgi = 1;
		//如果不是cgi程序,则直接发送文件,如果是cgi程序,重定向输入输出,启动cgi程序
        if (!cgi)
            serve_file(client, path);
        else
            execute_cgi(client, path, method, query_string);
    }

    close(client);
}

/**********************************************************************/
/* Inform the client that a request it has made has a problem.
 * Parameters: client socket */
/**********************************************************************/
void bad_request(int client)
{
    char buf[1024];

    sprintf(buf, "HTTP/1.0 400 BAD REQUEST\r\n");
    send(client, buf, sizeof(buf), 0);
    sprintf(buf, "Content-type: text/html\r\n");
    send(client, buf, sizeof(buf), 0);
    sprintf(buf, "\r\n");
    send(client, buf, sizeof(buf), 0);
    sprintf(buf, "<P>Your browser sent a bad request, ");
    send(client, buf, sizeof(buf), 0);
    sprintf(buf, "such as a POST without a Content-Length.\r\n");
    send(client, buf, sizeof(buf), 0);
}

/**********************************************************************/
/* Put the entire contents of a file out on a socket.  This function
 * is named after the UNIX "cat" command, because it might have been
 * easier just to do something like pipe, fork, and exec("cat").
 * Parameters: the client socket descriptor
 *             FILE pointer for the file to cat */
/**********************************************************************/
void cat(int client, FILE *resource)
{
    char buf[1024];

    fgets(buf, sizeof(buf), resource);
    while (!feof(resource))
    {
        send(client, buf, strlen(buf), 0);
        fgets(buf, sizeof(buf), resource);
    }
}

/**********************************************************************/
/* Inform the client that a CGI script could not be executed.
 * Parameter: the client socket descriptor. */
/**********************************************************************/
void cannot_execute(int client)
{
    char buf[1024];

    sprintf(buf, "HTTP/1.0 500 Internal Server Error\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "Content-type: text/html\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "<P>Error prohibited CGI execution.\r\n");
    send(client, buf, strlen(buf), 0);
}

/**********************************************************************/
/* Print out an error message with perror() (for system errors; based
 * on value of errno, which indicates system call errors) and exit the
 * program indicating an error. */
/**********************************************************************/
void error_die(const char *sc)
{
    perror(sc);
    exit(1);
}

/**********************************************************************/
/* Execute a CGI script.  Will need to set environment variables as
 * appropriate.
 * Parameters: client socket descriptor
 *             path to the CGI script */
/**********************************************************************/
void execute_cgi(int client, const char *path,
        const char *method, const char *query_string)
{
    char buf[1024];
    int cgi_output[2];
    int cgi_input[2];
    pid_t pid;
    int status;
    int i;
    char c;
    int numchars = 1;
    int content_length = -1;

    buf[0] = 'A'; buf[1] = '\0';
    if (strcasecmp(method, "GET") == 0)
        while ((numchars > 0) && strcmp("\n", buf))  /* read & discard headers */
            numchars = get_line(client, buf, sizeof(buf));
    else if (strcasecmp(method, "POST") == 0) /*POST*/
    {
        numchars = get_line(client, buf, sizeof(buf));
        while ((numchars > 0) && strcmp("\n", buf))
        {
        	//只要找到header部分的Content-Length
            buf[15] = '\0';
            if (strcasecmp(buf, "Content-Length:") == 0)
                content_length = atoi(&(buf[16]));
            numchars = get_line(client, buf, sizeof(buf));
        }
		//如果body长度为-1,告诉客户端产生了错误
        if (content_length == -1) {
            bad_request(client);
            return;
        }
    }
    else/*HEAD or other*/
    {
    }

	//如果创建所需要的资源失败,就调用cannot_execute,告诉客户端服务器进程出现错误
    if (pipe(cgi_output) < 0) {
        cannot_execute(client);
        return;
    }
    if (pipe(cgi_input) < 0) {
        cannot_execute(client);
        return;
    }

    if ( (pid = fork()) < 0 ) {
        cannot_execute(client);
        return;
    }
    sprintf(buf, "HTTP/1.0 200 OK\r\n");
    send(client, buf, strlen(buf), 0);
    if (pid == 0)  /* child: CGI script */
    {
        char meth_env[255];
        char query_env[255];
        char length_env[255];

        dup2(cgi_output[1], STDOUT);
        dup2(cgi_input[0], STDIN);
        close(cgi_output[0]);
        close(cgi_input[1]);
		//REQUEST_METHOD, QUERY_STRING, CONTENT_LENGTH 参数作为环境变量传递给cgi程序
        sprintf(meth_env, "REQUEST_METHOD=%s", method);
        putenv(meth_env);
        if (strcasecmp(method, "GET") == 0) {
            sprintf(query_env, "QUERY_STRING=%s", query_string);
            putenv(query_env);
        }
        else {   /* POST */
            sprintf(length_env, "CONTENT_LENGTH=%d", content_length);
            putenv(length_env);
        }
        execl(path, NULL);
        exit(0);
    } else {    /* parent */
        close(cgi_output[1]);
        close(cgi_input[0]);
        if (strcasecmp(method, "POST") == 0)
			//接受data部分,然后传给cgi程序
            for (i = 0; i < content_length; i++) {
                recv(client, &c, 1, 0);
                write(cgi_input[1], &c, 1);
            }
		//将cgi程序的输出传给客户端
        while (read(cgi_output[0], &c, 1) > 0)
            send(client, &c, 1, 0);

        close(cgi_output[0]);
        close(cgi_input[1]);
		//避免僵死进程,因为这里是一个线程,所以调用waitpid只会阻塞线程,不会阻塞主线程
        waitpid(pid, &status, 0);
    }
}

/**********************************************************************/
/* Get a line from a socket, whether the line ends in a newline,
 * carriage return, or a CRLF combination.  Terminates the string read
 * with a null character.  If no newline indicator is found before the
 * end of the buffer, the string is terminated with a null.  If any of
 * the above three line terminators is read, the last character of the
 * string will be a linefeed and the string will be terminated with a
 * null character.
 * Parameters: the socket descriptor
 *             the buffer to save the data in
 *             the size of the buffer
 * Returns: the number of bytes stored (excluding null) */
/**********************************************************************/
		//使用recv以字符为单位读取,直到读到/0或者size-1个字符已经读取完,或者已经读取不到数据了,返回读取字符的个数
int get_line(int sock, char *buf, int size)
{
    int i = 0;
    char c = '\0';
    int n;

    while ((i < size - 1) && (c != '\n'))
    {
        n = recv(sock, &c, 1, 0);
        /* DEBUG printf("%02X\n", c); */
        if (n > 0)
        {
            if (c == '\r')
            {
                n = recv(sock, &c, 1, MSG_PEEK);
                /* DEBUG printf("%02X\n", c); */
                if ((n > 0) && (c == '\n'))
                    recv(sock, &c, 1, 0);
                else
                    c = '\n';
            }
            buf[i] = c;
            i++;
        }
        else
            c = '\n';
    }
    buf[i] = '\0';

    return(i);
}
/*
感觉上一函数一次read一个太麻烦,这里是自己写的另一个版本,未测试
*/
/*int get_line(int sock, char *buf, int size)
{
	int n;
	int i;
	n = recv(sock, buf, size-1, MSG_PEEK);
	for(i = 0; i < n; i++)
	{
		if(buf[i] == '/n')
		{
			recv(sock, buf, i+1, 0);
			buf[i+1] = '/0';
			return i+1;
		}
		else if(buf[i] == '/r')
		{
			if(buf[i+1] == '/n')
			{
				recv(sock, buf, i+2, 0);
				buf[i] = '\n';
				buf[i+1] = '\0';
				return i+1;
			}
			else
			{
				recv(sock, buf, i+1, 0);
				buf[i] = '/n';
				buf[i+1] = '\0';
				return i+1;
			}
		}
	}
	buf[i] = '\n';
	buf[i+1] = '\0';
	return i+1;
}
*/

/**********************************************************************/
/* Return the informational HTTP headers about a file. */
/* Parameters: the socket to print the headers on
 *             the name of the file */
/**********************************************************************/
void headers(int client, const char *filename)
{
    char buf[1024];
    (void)filename;  /* could use filename to determine file type */

    strcpy(buf, "HTTP/1.0 200 OK\r\n");
    send(client, buf, strlen(buf), 0);
    strcpy(buf, SERVER_STRING);
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "Content-Type: text/html\r\n");
    send(client, buf, strlen(buf), 0);
    strcpy(buf, "\r\n");
    send(client, buf, strlen(buf), 0);
}

/**********************************************************************/
/* Give a client a 404 not found status message. */
/**********************************************************************/
void not_found(int client)
{
    char buf[1024];

    sprintf(buf, "HTTP/1.0 404 NOT FOUND\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, SERVER_STRING);
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "Content-Type: text/html\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "<HTML><TITLE>Not Found</TITLE>\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "<BODY><P>The server could not fulfill\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "your request because the resource specified\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "is unavailable or nonexistent.\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "</BODY></HTML>\r\n");
    send(client, buf, strlen(buf), 0);
}

/**********************************************************************/
/* Send a regular file to the client.  Use headers, and report
 * errors to client if they occur.
 * Parameters: a pointer to a file structure produced from the socket
 *              file descriptor
 *             the name of the file to serve */
/**********************************************************************/
//将url所指定的文件发送给客户端
//能进入到这个函数的是不带?的get请求,并且访问的url不是可执行程序
void serve_file(int client, const char *filename)
{
    FILE *resource = NULL;
    int numchars = 1;
    char buf[1024];

    buf[0] = 'A'; buf[1] = '\0';
	//只要丢弃header部分就行了,get没有data部分
    while ((numchars > 0) && strcmp("\n", buf))  /* read & discard headers */
        numchars = get_line(client, buf, sizeof(buf));

    resource = fopen(filename, "r");
    if (resource == NULL)
        not_found(client);
    else
    {
        headers(client, filename);
        cat(client, resource);
    }
    fclose(resource);
}

/**********************************************************************/
/* This function starts the process of listening for web connections
 * on a specified port.  If the port is 0, then dynamically allocate a
 * port and modify the original port variable to reflect the actual
 * port.
 * Parameters: pointer to variable containing the port to connect on
 * Returns: the socket */
/**********************************************************************/
int startup(u_short *port)
{
    int httpd = 0;
    int on = 1;
    struct sockaddr_in name;

    httpd = socket(PF_INET, SOCK_STREAM, 0);
    if (httpd == -1)
        error_die("socket");
    memset(&name, 0, sizeof(name));
    name.sin_family = AF_INET;
    name.sin_port = htons(*port);
    name.sin_addr.s_addr = htonl(INADDR_ANY);
    if ((setsockopt(httpd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) < 0)  
    {  
        error_die("setsockopt failed");
    }
    if (bind(httpd, (struct sockaddr *)&name, sizeof(name)) < 0)
        error_die("bind");
    if (*port == 0)  /* if dynamically allocating a port */
    {
        socklen_t namelen = sizeof(name);
        if (getsockname(httpd, (struct sockaddr *)&name, &namelen) == -1)
            error_die("getsockname");
        *port = ntohs(name.sin_port);
    }
    if (listen(httpd, 5) < 0)
        error_die("listen");
    return(httpd);
}

/**********************************************************************/
/* Inform the client that the requested web method has not been
 * implemented.
 * Parameter: the client socket */
/**********************************************************************/
void unimplemented(int client)
{
    char buf[1024];

    sprintf(buf, "HTTP/1.0 501 Method Not Implemented\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, SERVER_STRING);
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "Content-Type: text/html\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "<HTML><HEAD><TITLE>Method Not Implemented\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "</TITLE></HEAD>\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "<BODY><P>HTTP request method not supported.\r\n");
    send(client, buf, strlen(buf), 0);
    sprintf(buf, "</BODY></HTML>\r\n");
    send(client, buf, strlen(buf), 0);
}

/**********************************************************************/

int main(void)
{
    int server_sock = -1;
    u_short port = 4000;
    int client_sock = -1;
    struct sockaddr_in client_name;
    socklen_t  client_name_len = sizeof(client_name);
    pthread_t newthread;

    server_sock = startup(&port);
    printf("httpd running on port %d\n", port);

    while (1)
    {
        client_sock = accept(server_sock,
                (struct sockaddr *)&client_name,
                &client_name_len);
        if (client_sock == -1)
            error_die("accept");
        /* accept_request(&client_sock); */
        if (pthread_create(&newthread , NULL, (void *)accept_request, (void *)(intptr_t)client_sock) != 0)
            perror("pthread_create");
    }

    close(server_sock);

    return(0);
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

tinyhttpd代码注释 的相关文章

  • Python中 ''.JOIN()的用法

    Python join 方法 描述 将序列中的元素以指定的字符连接生成一个新的字符串 语法 语法 sep join seq 参数说明 sep 分隔符 可以为空 seq 要连接的元素序列 字符串 元组 字典 返回值 返回通过指定字符连接序列中
  • 机器自主学习创造新数据

    近年来 人工智能 AI 的发展带来了许多革命性的改变 其中 生成式AI Generative AI 也被称为AIGC Artificial IntelligenceGenerated Content 引起了人们的极大关注 生成式AI是一种使
  • 内存回收

    内存回收 内存状态分为 使用 未使用 可回收 这几点有啥区别 使用 标记状态已使用 未使用 使用地址到结束地址 可回收 标记状态为回收 怎么判断内存可回收 因为调用释放接口了 怎么回收性能高 批量回收 不要回收太频繁 避免磁盘碎片 磁盘内碎
  • QT基础:QPainte 绘制文本并设置动态设置字体演示

    QPainte 是QT里面的一个绘制控件 这里演示的是 用 QPainte 绘制一个文本 并通过 ui 上的 fontComboBox 控件 改变文本字体后触发 widget 槽函数 update 来刷新界面 演示过于简单 适合初学者食用
  • 揭开gRPC神秘面纱

    一 什么是RPC RPC Remote Procedure Call 远程过程调用 它是一种通过网络从远程计算机程序上请求服务 而不需要了解底层网络技术的思想 RPC 是一种技术思想而非一种规范或协议 常见 RPC 技术和框架有 应用级的服
  • el-submenu实现单个菜单折叠

    以上的效果就是 我打开 系统管理 折叠框 然后再打开 采集服务器 折叠框 这样一来的话就会让这个navMenu显得很高 严重的情况 就会撑破整个页面 怎么办呢 element代码实现如下
  • 进程和线程、协程的区别

    一 进程 进程是程序一次动态执行的过程 是程序运行的基本单位 每个进程都有自己的独立内存空间 不同进程通过进程间通信来通信 进程占据独立的内存 所以上下文进程间的切换开销 栈 寄存器 页表 文件句柄等 比较大 但相对比较稳定安全 协程切换和
  • ESP32C3对接阿里云生活物联网平台

    文章目录 1 装好ESP32 VSCode开发环境 2 git阿里云代码 3 先编译例程 看看能否编译成功 4 创建分区表 增加ota分区 5 查看分区空间 6 擦除整片Flash 7 未烧录四元组情况下 看看会报什么错 8 阿里云四元组
  • 使用EDU邮箱申请JetBrains学生包免费使用一年JetBrains全家桶

    写在最前 使用EDU邮箱申请JetBrains学生包可以免费使用一年JetBrains全家桶 欢迎光顾本人的博客 以后会经常记录生活点滴 学习工作所见 1 首先你需要一个EDU邮箱 JetBrains学生包的申请很简单 所以国内的EDU邮箱

随机推荐

  • java后台地址(省,市,区)、姓名、手机号算法智能识别

    最近项目中需要根据前台需要识别的信息去做后台处理 根据地址识别出来姓名 手机号 以及地址信息返回给前端 我借用了一套算法 这套算法是androi开发时候用的 我门java用的时候需要修改里面部分内容 用的时候项目中也必须要有封装好的省 市
  • BigDecimal转String类型

    从数据库取出一个NUMBER类型的值 在代码中要转成Integer类型的时候 代码如下 int a map get CONSTRICTION 报错 Cannot cast from Object to int Integer parseIn
  • OpenWrt UCI 学习笔记

    UCI Unified Configuration Interface 统一配置接口 是OpenWrt的集中配置管理工具 关于UCI的具体介绍可以查看官方文档 The UCI System 可以通过ubuntu安装UCI或使用openwrt
  • 当语音识别搭配AI之后,我的语音助手更懂我的心了

    欢迎大家前往腾讯云 社区 获取更多腾讯海量技术实践干货哦 本文由腾讯云AI中心发表于云 社区专栏 我今天演讲主要分四个部分 第一个是分享语音识别概述 然后是深度神经网络的基础 接下来就是深度学习在语音识别声学模型上面的应用 最后要分享的是语
  • MapReduce分片阶段详解

    MapReduce作为第一代的大数据计算引擎 其经典地位至今仍然得到认可 MapReduce之后的Spark计算引擎 本质上来说 依然是借用了MapReduce的核心思想 今天的大数据技术分享 我们就主要来讲讲MapReduce计算前的准备
  • 关于jsp文件中写System类报错问题

    我最近在学习javaWeb时出现几个莫名其妙的问题 我解决问题之后 觉得还是把这些坑都写清楚 方便javaweb的初学者避坑 用IDEA的tomcat7插件或者tomcat低版本 JDK高版本会遇到这个问题 我刚开始用的是IDEA的tomc
  • python判断今天周几_如何用python判断今天是星期几

    本文利用Python计算今天日期 明天日期 和昨天日期的相关方法 及获取当前日期是星期几 python编程操作日期时间主要用到的python模块是datetime和time这2个模块 获取星期几from datetime import da
  • K8S部署rocketmq单机和集群

    K8S部署rocketmq单机和集群 版本 Rocketmq介绍 RocketMQ 的核心概念 2 1 Topic Queue tags 2 2 Producer 与 Producer Group 2 3 Consumer 与 Consum
  • 子网计算方法

    问题 把192 168 253 0 28划分多个子网 请列出所有的可用子网段和对应主机范围 解 1 计算子网 掩码为28个1 即11111111 11111111 11111111 11110000 点分十进制表示为255 255 255
  • 补码除法运算(加减交替法)

    x 补 00 1000 除数y 补 11 0101 两个数是异号 因此使用x 补 y 补 11 1101 11 1101继续与y 补 对比 发现是同号 商上1 余数11 1101向左移动一位 再加上 y 补 结果为00 0101 余数00
  • 在家靠python爬虫兼职月入3w+:成年人的世界,钱是底气!

    在2023年新一轮疫情期间 有啥方法 可在家快速赚钱 冲上了热门话题 好想挣钱啊 单位难开工 生意不开张 咱们才惊醒 领死工资的生活 真的好脆弱 平时总说副业赚钱 但也就说说而已 副业在哪 钱在哪 都没影 现实是 副业 低端兼职 赔本买卖
  • JS 跳过 debugger 的几种方法

    js中通常用debugger关键字来实现无限循环 js中通常用debugger关键字来实现无限循环 debugger 语句用于停止执行 JavaScript 以下简称JS 并调用 如果可用 调试函数 使用 debugger 语句类似于在代码
  • map结构用法

    map结构是所谓的映射关系 其元素组成部分为键值对的形式存在 key value 其中键 key 不可重复 头文件引用 include
  • 服务器系统与环境变量,什么叫Web服务器的环境变量

    服务器环境变量的详细说明 本机ip request servervariables remote addr br 服务器名 Request ServerVariables SERVER NAME br 服务器IP Request Serve
  • 疫情期间,程序员开展副业的时候怎么和客户沟通呢?记住下面这几条,是你有一桶金的第一步!

    不同的身份 一直对自由职业报有期待 虽然现在还是一颗螺丝钉 我想 为了更好的创造自己的价值 我可否用自己的技能做一些东西呢 于是 工作之外 我开始寻找接单做项目 现在 这种程序员接单的平台有很多 国内国外都有 可是万事开头难 有这种渠道不一
  • Java 虚拟机内部类静态字段的初始化与访问

    要明白 Java 虚拟机如何访问类的静态变量 首先要明白下面几个问题 虚拟机内部是如何表示一个 Java 类的 静态变量存储在哪里 虚拟机如何访问到这些静态变量 这篇文章也从这围绕这三个问题展开 并结合 OpenJDK 中 HotSpot
  • [LeetCode]62. 不同路径

    62 不同路径 难度 中等 一个机器人位于一个 m x n 网格的左上角 起始点在下图中标记为 Start 机器人每次只能向下或者向右移动一步 机器人试图达到网格的右下角 在下图中标记为 Finish 问总共有多少条不同的路径 示例 1 输
  • vuepress2.0使用教程(10)-从零开始搭建自定义模板

    百家饭团队开发的百家饭OpenAPI平台是用vuepress2 0搭建的 搭建的时候不知道2 0还处在beta状态 所以导致后来踩了一些坑 使用过程中vuepress2 0也从2 0 0 beta 18升到了2 0 0 beta 48 有很
  • JS逆向新技术--JSRPC

    声明 本文章中所有内容仅供学习交流 不可用于任何商业用途和非法用途 否则后果自负 如有侵权 请联系作者立即删除 由于本人水平有限 如有理解或者描述不准确的地方 还望各位大佬指教 介绍 JSRPC意思就是远程调用js代码 全称 Remote
  • tinyhttpd代码注释

    J David s webserver This is a simple webserver Created November 1999 by J David Blackstone CSE 4344 Network concepts Pro