Commit Graph
133 Commits
Author SHA1 Message Date
cozis b8eaeedd58 Increate output buffer limit to 16MB 2025-12-18 13:55:36 +01:00
cozis 7f0c638b62 Don't assert that requests have a host header 2025-12-18 10:37:28 +01:00
cozis 02d8206e9d Load full certificate chains, not just the leafs 2025-12-15 23:08:31 +01:00
cozis 2eb6a5fe9d Free SSL socket objects when clients disconnect from the server 2025-12-15 22:37:40 +01:00
cozis e2d52f8b63 Bug fix triggered by HTTPS connections 2025-12-15 22:23:07 +01:00
cozis f3345ba670 Properly mark server connections as FREE when they are deinitialized 2025-12-15 22:22:43 +01:00
cozis c681590fa2 Fix typo in assertion 2025-12-15 08:45:06 +01:00
cozis 1f9411119a Add request timeouts 2025-12-12 22:36:27 +01:00
cozis b361125bc3 Add second argument to _Static_assert to silence clang warnings 2025-12-12 19:53:53 +01:00
cozis 04deae62d6 Replace http_/HTTP_ prefixes with chttp_/CHTTP_ 2025-12-09 12:12:21 +01:00
cozis db030b3834 Add missing OpenSSL include 2025-12-09 08:57:39 +01:00
cozis e686e477e2 Ignore socket events when an HTTP response is being built by the user 2025-12-03 18:40:26 +01:00
cozis f6d81c1a87 Add -Wall -Wextra flags to the build script and fix the resulting compiler warnings 2025-12-02 12:02:59 +01:00
cozis f1fd633356 Add Content-Length to HTTP requests 2025-11-29 21:28:56 +01:00
cozis 64b40dfac7 Close socket when an HTTP response is received 2025-11-29 19:56:54 +01:00
cozis 954bcb7e3e Add option for HTTPS clients to not verify the peer's certificate 2025-11-29 19:56:09 +01:00
cozis 008772aef1 Fix bug in response builder state machine 2025-11-27 21:02:31 +01:00
cozis 1ef6187b2d Add simplified client API (http_get, http_put, http_post, http_delete) 2025-11-27 09:50:41 +01:00
cozis 6a9ba6bbf4 Add HTTPS server examples 2025-11-27 09:24:46 +01:00
cozis 73086ca164 Add numbering prefix to examples 2025-11-27 09:09:13 +01:00
cozis 93c989b56f Add virtual hosts example 2025-11-27 09:00:27 +01:00
cozis b87a78a023 Add proxy example (draft) 2025-11-27 00:32:12 +01:00
cozis c4c41653f4 Add error codes 2025-11-26 22:38:37 +01:00
cozis a58dc241ef Rename http_request_builder_set_trace_bytes to *_trace 2025-11-26 21:13:56 +01:00
cozis 0c50cbff33 Separate http_request_builder_url into http_request_builder_method/_target 2025-11-26 21:11:39 +01:00
cozis 5706f12298 If a socket manager finds winsock uninitialized, it will initialize it and remember to deinitialize it at cleanup 2025-11-26 16:30:59 +01:00
cozis bb753ad8ee Add support for HTTPS, Windows, and Linux builds to Makefile 2025-11-26 16:10:52 +01:00
cozis 52ee89252c Properly consume socket events in the server when the socket manager reports them 2025-11-26 15:42:05 +01:00
cozis 749aef7c8d Add debug code to trace socket state transitions and fix bug in response parser where a space was consumed twice 2025-11-26 15:33:15 +01:00
cozis aa158980f5 Set expected certificate hostname when connecting to an HTTPS server 2025-11-23 23:54:10 +01:00
cozis 1be0c14415 Bug fix 2025-11-23 23:49:56 +01:00
cozis 9f0560fb9e Add http_client_wait_response for client who don't care about calling poll() directly 2025-11-23 23:39:48 +01:00
cozis f6b2c805c6 Fix HTTP request creation and simple client example 2025-11-23 23:27:08 +01:00
cozis 3c0aecb5f0 Bug fixes & cleanups 2025-11-23 23:07:08 +01:00
cozis 655289e542 Merge branch 'cookie_jar' into refactoring
# Conflicts:
#	chttp.h
#	src/client.h
2025-11-23 22:36:01 +01:00
Claude 7ce2765875 Add back url_buffer as HTTP_String
Making the URL buffer allocation more explicit by storing it as
an HTTP_String. This provides both the pointer and length, making
the code clearer and more self-documenting.
2025-11-23 21:29:13 +00:00
Claude b924f0772c Remove redundant url_buffer field
Use url.scheme.ptr directly for freeing the allocated URL string,
since the scheme is always at the start of a URL. This saves 8 bytes
per connection and simplifies the code.
2025-11-23 21:28:13 +00:00
Claude e87fa490df Fix dangling pointer bug in URL storage
The previous implementation stored parsed_url which contained pointers
into the user's string literal that could be invalidated. This fix:

1. Allocates a copy of the URL string (url_buffer)
2. Parses the copy so all pointers reference owned memory
3. Removes redundant domain and path fields from HTTP_ClientConn
4. Updates save_cookies to use url.authority.host.text and url.path
5. Updates cleanup code to free url_buffer instead of domain.ptr

This ensures the URL and all its components remain valid for the
lifetime of the connection.
2025-11-23 21:26:59 +00:00
Claude 737d81f270 Fix compilation errors in cookie_jar branch
This commit fixes multiple compilation errors introduced by the refactoring:

1. Added missing http_client_conn_free() helper function
2. Fixed cookie_jar reference (cookie_jar->count to client->cookie_jar.count)
3. Restored missing HTTP_ClientConn fields: handle, client, and url
4. Fixed undefined 'conn' variable in http_client_get_builder (changed to 'i')
5. Fixed incorrect field reference (entry.domain.len to domain.len)
6. Added missing closing parenthesis in should_send_cookie
7. Removed duplicate 'path' variable declaration
8. Fixed cookie jar access to use builder.client instead of conn->client
9. Fixed byte_queue_write calls to use .ptr and .len instead of HTTP_String structs
10. Fixed missing -> operators in url_to_connect_target
11. Fixed undefined 'url' variable by using conn->url
12. Fixed headers[i].value to set_cookie.value in save_one_cookie
13. Fixed typo: antry to entry
14. Fixed save_one_cookie parameter type (headers[i] instead of headers[i].value)
15. Fixed print_bytes calls to create HTTP_String structs
16. Added logic to store socket handle when connection is established
17. Updated http_client_get_builder signature to return HTTP_RequestBuilder
18. Updated simple_client.c example to match new API
2025-11-23 21:18:09 +00:00
cozis 39d90111c9 Refactoring of the HTTP client 2025-11-23 22:11:15 +01:00
cozis e5358d883b Add Cookie headers when starting an HTTP request 2025-11-23 19:22:38 +01:00
cozis fc49b55225 Add HTTP_CookieJar object to HTTP_Client 2025-11-23 17:38:53 +01:00
Claude 6cb5bdacd2 Complete Set-Cookie header parser implementation
Implemented missing functionality in the Set-Cookie parser:

1. Completed is_cookie_octet() function to properly validate cookie characters
   according to RFC 6265 (excludes CTLs, whitespace, DQUOTE, comma, semicolon, backslash)

2. Fixed http_parse_set_cookie() return type from void to int to properly
   report parsing errors

3. Implemented Path attribute parsing to extract cookie path restrictions

4. Fixed HttpOnly attribute bug where it was incorrectly set to false instead of true

5. Added path field to HTTP_SetCookie struct with have_path flag

6. Added missing return 0 statement for successful parsing

7. Exported Set-Cookie parser types and function to public API:
   - HTTP_WeekDay, HTTP_Month, HTTP_Date enums/struct
   - HTTP_SetCookie struct
   - http_parse_set_cookie() function

All changes follow RFC 6265 specification for Set-Cookie header parsing.
2025-11-23 15:59:31 +00:00
cozis 48ad83934b Progress on Set-Cookie header parser 2025-11-23 16:51:05 +01:00
cozis cb80bc3c14 Fix typo 2025-11-23 09:29:32 +01:00
cozis fa9b0e9919 Add zero-copy interface version of http_response_builder_body 2025-11-22 23:51:43 +01:00
cozis b881feb93a Define HTTP_SERVER_POLL_CAPACITY and HTTP_CLIENT_POLL_CAPACITY so that users can easily allocate poll arrays of the right size 2025-11-22 22:55:50 +01:00
cozis fe1c0d5b86 Draft of the Set-Cookie header parser 2025-11-22 22:31:29 +01:00
cozis 4ca5b67d8e Add a client example program and move examples to the examples/ folder 2025-11-22 00:13:43 +01:00
cozis eec1174047 Fix issues that caused the server to hang 2025-11-21 23:57:24 +01:00