Commit 4f85f5a5b42cd954637453e8eec084752d796482
- Diff rendering mode:
- inline
- side by side
external/mongoose/mongoose.c
(16 / 3)
|   | |||
| 2832 | 2832 | strncmp(ri->http_version, "HTTP/", 5) == 0) { | |
| 2833 | 2833 | ri->http_version += 5; /* Skip "HTTP/" */ | |
| 2834 | 2834 | parse_http_headers(&buf, ri); | |
| 2835 | ri->remote_port = ntohs(usa->u.sin.sin_port); | ||
| 2836 | (void) memcpy(&ri->remote_ip, &usa->u.sin.sin_addr.s_addr, 4); | ||
| 2837 | ri->remote_ip = ntohl(ri->remote_ip); | ||
| 2838 | 2835 | success_code = TRUE; | |
| 2839 | 2836 | } | |
| 2840 | 2837 | ||
| … | … | ||
| 2839 | 2839 | } | |
| 2840 | 2840 | ||
| 2841 | 2841 | /* | |
| 2842 | * Extract IP/port from connection, fill in mg_request_info structure. | ||
| 2843 | */ | ||
| 2844 | static void | ||
| 2845 | extract_socket_info(struct mg_connection *conn) | ||
| 2846 | { | ||
| 2847 | struct mg_request_info *ri = &conn->request_info; | ||
| 2848 | const struct usa *usa = &conn->client.rsa; | ||
| 2849 | |||
| 2850 | ri->remote_port = ntohs(usa->u.sin.sin_port); | ||
| 2851 | (void) memcpy(&ri->remote_ip, &usa->u.sin.sin_addr.s_addr, 4); | ||
| 2852 | ri->remote_ip = ntohl(ri->remote_ip); | ||
| 2853 | } | ||
| 2854 | |||
| 2855 | /* | ||
| 2842 | 2856 | * Keep reading the input (either opened file descriptor fd, or socket sock, | |
| 2843 | 2857 | * or SSL descriptor ssl) into buffer buf, until \r\n\r\n appears in the | |
| 2844 | 2858 | * buffer (which marks the end of HTTP request). Buffer buf may already | |
| … | … | ||
| 4522 | 4522 | while (get_socket(ctx, &conn.client) == TRUE) { | |
| 4523 | 4523 | conn.birth_time = time(NULL); | |
| 4524 | 4524 | conn.ctx = ctx; | |
| 4525 | |||
| 4526 | extract_socket_info(&conn); | ||
| 4525 | 4527 | ||
| 4526 | 4528 | if (conn.client.is_ssl && | |
| 4527 | 4529 | (conn.ssl = SSL_new(conn.ctx->ssl_ctx)) == NULL) { |

