Why does server exit with body over certain length?

This page summarizes the projects mentioned and recommended in the original post on /r/C_Programming

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • private-network-access

  • // man getsockname // Get client address int sockn = getsockname(request, (struct sockaddr*)&client_addr, (socklen_t*)&client_addrlen); if (sockn < 0) { JS_ThrowInternalError(ctx, "server error (getsockname): %s", strerror(errno)); continue; } char buffer[BUFFER_SIZE]; // man 2 read // Read from the socket int readable = read(request, buffer, BUFFER_SIZE); if (readable < 0) { JS_ThrowInternalError(ctx, "server error (read): %s", strerror(errno)); continue; } // man sscanf // man inet_ntoa // man ntohs // Read the request char method[128], uri[128], version[128]; sscanf(buffer, "%s %s %s", method, uri, version); // ... if (!strcmp(method, "QUERY") || !strcmp(method, "POST")) { // https://developer.chrome.com/blog/private-network-access-preflight/ // https://wicg.github.io/local-network-access/ char response[] = "HTTP/1.1 200 OK\r\n" "Server: webserver-c\r\n" "Cross-Origin-Opener-Policy: unsafe-none\r\n" "Connection: keepalive\r\n" "Cross-Origin-Embedder-Policy: unsafe-none\r\n" "Access-Control-Allow-Headers: cache-control\r\n" "Access-Control-Allow-Methods: OPTIONS,POST,GET,HEAD,QUERY\r\n" "Access-Control-Allow-Credentials: true\r\n" "Cache-Control: no-store\r\n" "Access-Control-Allow-Origin: *\r\n" "Content-type: text/plain\r\n" "Access-Control-Allow-Private-Network: true\r\n\r\n"; char* body_signal = strstr(buffer, "\r\n\r\n"); char* body = body_signal + 4; status(ctx, argv[1], body); uint8_t writable[65536]; int writer = write(request, response, strlen(response)); if (writer < 0) { return JS_ThrowInternalError(ctx, "server error (write): %s", strerror(errno)); } // man popen FILE* pipe = popen(body, "r"); if (pipe == NULL) { return JS_ThrowInternalError(ctx, "server error (popen): %s", strerror(errno)); } for (;;) { // man fread size_t count = fread(writable, 1, sizeof(writable), pipe); int stream = write(request, writable, count); if (stream < 0 || count == 0) { // man pclose pclose(pipe); status(ctx, argv[1], "aborted"); break; } } close(request); for (int i = 0; i < sizeof(buffer) - 1; i++) { buffer[i] = '\0'; }

  • webserver-c

    A simple HTTP webserver written in C.

  • Not sure. This is the original code https://github.com/guest271314/webserver-c that uses getsockname().

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • native-messaging-c

    C Native Messaging host

  • Ultimately what I am trying to do is test the simplicity and efficiency of using a local server versus using Native Messaging, which I have working https://github.com/guest271314/native-messaging-c, https://github.com/guest271314/captureSystemAudio/blob/master/native_messaging/capture_system_audio/capture_system_audio.c.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • JavaScript Standard Input/Output: Unspecified

    7 projects | /r/learnjavascript | 17 Nov 2023
  • Full-duplex streaming with fetch() to and from the browser using Native Messaging

    1 project | /r/javascript | 3 Nov 2023
  • How can i monitor my linux terminal in a web app?

    4 projects | /r/node | 10 Jul 2023
  • how to execute code with javascript and get the result

    1 project | /r/learnjavascript | 10 Jul 2023
  • Have we reached a point of no return on managing software dependencies?

    1 project | /r/programming | 9 Jul 2023