Skip to content

feat: HTTP/1.1 chunked transfer encoding#51

Merged
mgrossmann merged 7 commits into
mainfrom
issue-50-chunked-transfer-encoding
Apr 9, 2026
Merged

feat: HTTP/1.1 chunked transfer encoding#51
mgrossmann merged 7 commits into
mainfrom
issue-50-chunked-transfer-encoding

Conversation

@mgrossmann
Copy link
Copy Markdown
Contributor

@mgrossmann mgrossmann commented Apr 9, 2026

Summary

  • Upgrades response protocol from HTTP/1.0 to HTTP/1.1
  • Implements RFC 7230 chunked transfer encoding for responses without known Content-Length
  • Static UFS files get Content-Length via ufs_stat(), SSI-processed files use chunked
  • Validates Host header (400 Bad Request if missing on HTTP/1.1 requests)
  • Adds Connection: close on all responses (keep-alive is a separate phase)
  • Response version mirrors client version (HTTP/1.0 clients get HTTP/1.0 response)
  • CGI modules (mvsMF) are unaffected — they already set Content-Length

Changed files

File Change
include/httpd.h New HTTPC fields: chunked (0x41), content_length_set (0x52)
include/httpcgi.h Mirror HTTPC layout changes for CGI headers
src/httpresp.c HTTP/1.1 response line (or 1.0 for 1.0 clients), Connection: close
src/httpsend.c Chunk framing via send_raw() helper when chunked==1
src/httpdone.c Send terminating chunk 0\r\n\r\n before CSTATE_REPORT
src/httpget.c Content-Length for non-SSI UFS files, chunked for SSI (HTTP/1.1 only)
src/httppars.c SERVER_PROTOCOL → HTTP/1.1
src/httpin.c Host header validation for HTTP/1.1
src/httprese.c Reset chunked and content_length_set between requests

Test results

  • HTTP/1.1 response line
  • HTTP/1.0 client → HTTP/1.0 response, no chunked
  • Chunked for HTML/SSI files (size unknown at open time)
  • Content-Length for static non-SSI files (e.g. favicon: 32038 bytes)
  • mvsMF JSON endpoints → Content-Length (set by mvsMF)
  • Missing Host header → 400 Bad Request
  • Binary file download with Content-Length
  • 404 for missing files
  • Zowe CLI — no regressions

Fixes #50

- Response line upgraded from HTTP/1.0 to HTTP/1.1
- Connection: close header sent on all responses (keep-alive planned)
- Chunked transfer encoding for responses without known Content-Length
- Content-Length header for static UFS files via ufs_stat()
- SSI-processed files use chunked encoding (unknown output size)
- Host header validation: 400 Bad Request if missing on HTTP/1.1
- SERVER_PROTOCOL env var updated to HTTP/1.1
- Terminating chunk (0\r\n\r\n) sent in httpdone before CSTATE_REPORT
- New HTTPC fields: chunked (0x41), content_length_set (0x52)
- Fields reset in httprese.c between requests

CGI modules (mvsMF) are unaffected — they already set Content-Length
via sendDefaultHeaders() and never enable chunked mode.

Fixes #50
Bug 1: HTTP/1.0 clients received chunked responses which they cannot
parse. Now httpresp.c mirrors the client version in the response line
(HTTP/1.0 or HTTP/1.1), and httpget.c only uses Transfer-Encoding:
chunked for HTTP/1.1 clients. HTTP/1.0 bodies are delimited by
Connection: close as before.

Bug 2: ufs_stat() returns non-zero for all static files, causing
Content-Length to never be set. Added HTTPD050I diagnostic message
logging the path and return code to identify the root cause.

Fixes #50
wtof at entry showing chunked flag and data length, and after
sprintf showing the chunk header bytes before EBCDIC-to-ASCII
conversion. To be removed once the chunked encoding issue is
resolved.

Ref #50
The Bug-1 fix moved httpc->chunked=1 inside the version check block,
accidentally placing it BEFORE the header-terminating "\r\n" was sent.
This caused the blank line separator to be chunk-framed, which curl
interpreted as a malformed header ("Header without colon").

Now uses a local use_chunked flag and sets httpc->chunked only after
the "\r\n" has been sent as raw data.

Fixes #50
Remove HTTPSEND chunked/len trace and HTTPD050I ufs_stat diagnostic
that were added to diagnose the chunked encoding issues. The chunked
framing bug (chunked flag set before header CRLF) is fixed.

Ref #50
Accidentally removed in previous cleanup. This trace is still needed
to diagnose why ufs_stat fails for static files (Bug 2).

Ref #50
ufs_stat() confirmed working — Content-Length is set correctly for
non-SSI static files. HTML files use chunked encoding by design
because SSI processing makes the final output size unknown.

Ref #50
@mgrossmann mgrossmann merged commit 02e2479 into main Apr 9, 2026
1 check failed
@mgrossmann mgrossmann deleted the issue-50-chunked-transfer-encoding branch April 9, 2026 17:56
@mgrossmann mgrossmann mentioned this pull request Apr 11, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 3: Chunked Transfer Encoding for responses

1 participant