Skip to content

Commit

Permalink
MicroHTTPKit: Fix POST data processing
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder committed Mar 11, 2024
1 parent d240f4e commit d56cbc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Libraries/MicroHTTPKit/Source/HKHTTPServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ static enum MHD_Result accessHandler(void *cls, struct MHD_Connection *connectio

server = (__bridge HKHTTPServer *) cls;

// Log all arguments with nslog
NSLog(@"Received request for method %s; URL %s; %lu bytes of upload data", method, url,
*upload_data_size);

if (*con_cls == NULL) {
NSString *urlString;
NSString *methodString;
Expand Down Expand Up @@ -112,6 +116,8 @@ static enum MHD_Result accessHandler(void *cls, struct MHD_Connection *connectio
// This is a __bridge_retained cast, so we need to release the object later on
*con_cls = (__bridge_retained void *) (request);
HKDefaultConnectionLogger(request);

return MHD_YES;
} else {
// This is a subsequent call for this request, so we need to retrieve the request
// object from the connection class
Expand Down
3 changes: 1 addition & 2 deletions Libraries/MicroHTTPKit/Tests/routing.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ - (void)testPOST {
encoding:NSUTF8StringEncoding];

XCTAssertNotNil(data, @"Body data is valid");
// FIXME: We need to implement a post-processor in HKHTTPServer.m for the body
// data to be correctly passed
XCTAssertEqualObjects(body, REQUEST_BODY_STRING, @"Body data is valid");

return [HKHTTPResponse
responseWithData:[RESPONSE_STRING dataUsingEncoding:NSUTF8StringEncoding]
Expand Down

0 comments on commit d56cbc0

Please sign in to comment.