Home | History | Annotate | Download | only in isc

Lines Matching defs:httpd

1 /*	$NetBSD: httpd.c,v 1.13 2026/08/29 14:55:18 christos Exp $	*/
24 #include <isc/httpd.h>
157 isc_httpd_t *httpd;
201 httpd_free(isc_httpd_t *httpd);
360 process_request(isc_httpd_t *httpd, size_t last_len) {
372 pret = phr_parse_request(httpd->recvbuf, httpd->recvlen, &method,
374 &httpd->minor_version, headers, &num_headers,
391 httpd->consume = pret;
398 httpd->method = METHOD_GET;
400 httpd->method = METHOD_POST;
408 result = isc_url_parse(path, path_len, 0, &httpd->up);
412 httpd->path = path;
417 httpd->flags = 0;
423 isc_time_set(&httpd->if_modified_since, 0, 0);
449 httpd->flags |= CONNECTION_CLOSE;
458 httpd->flags |= ACCEPT_DEFLATE;
469 timestamp, &httpd->if_modified_since);
477 if (httpd->method == METHOD_GET && content_len != 0) {
485 size_t consume = httpd->consume + content_len;
486 if (consume > httpd->recvlen) {
492 httpd->consume = consume;
494 switch (httpd->minor_version) {
500 if ((httpd->flags & CONNECTION_CLOSE) == 0 && keep_alive) {
501 httpd->flags |= CONNECTION_KEEP_ALIVE;
503 httpd->flags |= CONNECTION_CLOSE;
527 httpd_free(isc_httpd_t *httpd) {
530 REQUIRE(VALID_HTTPD(httpd));
532 httpdmgr = httpd->mgr;
537 ISC_LIST_UNLINK(httpdmgr->running, httpd, link);
540 httpd->recvbuf[0] = 0;
541 httpd->recvlen = 0;
542 httpd->consume = 0;
543 httpd->method = METHOD_UNKNOWN;
544 httpd->flags = 0;
546 httpd->minor_version = -1;
547 httpd->path = NULL;
548 httpd->up = (isc_url_parser_t){ 0 };
549 isc_time_set(&httpd->if_modified_since, 0, 0);
551 httpd->magic = 0;
552 httpd->mgr = NULL;
554 isc_mem_put(httpdmgr->mctx, httpd, sizeof(*httpd));
581 isc__httpd_sendreq_new(isc_httpd_t *httpd) {
582 isc_httpdmgr_t *httpdmgr = httpd->mgr;
600 isc_httpd_attach(httpd, &req->httpd);
607 isc_httpd_t *httpd = NULL;
611 httpd = isc_mem_get(httpdmgr->mctx, sizeof(*httpd));
612 *httpd = (isc_httpd_t){
618 isc_nmhandle_attach(handle, &httpd->handle);
620 isc_httpdmgr_attach(httpdmgr, &httpd->mgr);
623 ISC_LIST_APPEND(httpdmgr->running, httpd, link);
626 isc_nm_read(handle, httpd_request, httpd);
658 render_404(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, void *arg,
663 UNUSED(httpd);
679 render_500(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, void *arg,
684 UNUSED(httpd);
701 * Tries to compress httpd->bodybuffer to httpd->compbuffer, extending it
705 *\li httpd a valid isc_httpd_t object
756 isc_httpd_t *httpd = req->httpd;
757 isc_httpdmgr_t *mgr = httpd->mgr;
766 REQUIRE(VALID_HTTPD(httpd));
771 if (httpd->up.field_set & (1 << ISC_UF_PATH)) {
772 path = &httpd->path[httpd->up.field_data[ISC_UF_PATH].off];
773 path_len = httpd->up.field_data[ISC_UF_PATH].len;
785 result = mgr->render_404(httpd, NULL, NULL, &req->retcode,
790 result = url->action(httpd, url, url->action_arg, &req->retcode,
796 result = mgr->render_500(httpd, url, NULL, &req->retcode,
804 if ((httpd->flags & ACCEPT_DEFLATE) != 0) {
812 httpd_response(httpd, req);
814 if ((httpd->flags & CONNECTION_CLOSE) != 0) {
816 } else if ((httpd->flags & CONNECTION_KEEP_ALIVE) != 0) {
850 * the response headers and store the result in httpd->sendbuffer.
869 INSIST(httpd->consume != 0);
870 INSIST(httpd->consume <= httpd->recvlen);
871 if (httpd->consume < httpd->recvlen) {
872 memmove(httpd->recvbuf, httpd->recvbuf + httpd->consume,
873 httpd->recvlen - httpd->consume);
875 httpd->recvlen -= httpd->consume;
876 httpd->consume = 0;
885 isc_httpd_t *httpd = req->httpd;
893 httpd_senddone(httpd->handle, result, req);
897 isc_nm_send(httpd->handle, &r, httpd_senddone, req);
903 isc_httpd_t *httpd = arg;
904 isc_httpdmgr_t *mgr = httpd->mgr;
908 REQUIRE(VALID_HTTPD(httpd));
910 REQUIRE(httpd->handle == handle);
923 * data in the httpd->recvbuf.
925 last_len = (region == NULL) ? 0 : httpd->recvlen;
929 if (httpd->recvlen + region->length > sizeof(httpd->recvbuf)) {
933 memmove(httpd->recvbuf + httpd->recvlen, region->base,
935 httpd->recvlen += region->length;
938 result = process_request(httpd, last_len);
941 if (httpd->recvlen > HTTP_MAX_REQUEST_LEN) {
955 isc_httpd_sendreq_t *req = isc__httpd_sendreq_new(httpd);
962 isc_nmhandle_close(httpd->handle);
963 isc_nmhandle_detach(&httpd->handle);
965 isc_httpd_detach(&httpd);
982 isc_httpd_t *httpd = NULL, *next = NULL;
983 ISC_LIST_FOREACH_SAFE(httpdmgr->running, httpd, link, next) {
984 if (httpd->handle != NULL) {
985 httpd_request(httpd->handle, ISC_R_SUCCESS, NULL,
986 httpd);
1000 httpd_response(isc_httpd_t *httpd, isc_httpd_sendreq_t *req) {
1004 httpd->minor_version, req->retcode,
1045 isc_httpd_t *httpd = req->httpd;
1047 REQUIRE(VALID_HTTPD(httpd));
1049 if ((httpd->mgr->flags & ISC_HTTPDMGR_SHUTTINGDOWN) != 0) {
1053 if (eresult == ISC_R_SUCCESS && (httpd->flags & CONNECTION_CLOSE) != 0)
1061 httpd_request(handle, eresult, NULL, httpd);
1066 isc_httpd_detach(&httpd);
1119 isc_httpd_if_modified_since(const isc_httpd_t *httpd) {
1120 return (const isc_time_t *)&httpd->if_modified_since;