1
NXPTM M522XX, KINETIS and i.MX RT / Re: Post method
« on: January 23, 2026, 12:29:37 AM »
Hi
Here are few additional tips about handling POST to a web server.
1. Use WireShark to view the POST that is being received to be sure that the type is known. For example if text based content is being received the POST header will contain the content type "text/plain".
2. Ensure that the type is supported by the HTTP server - for example
#define SUPPORT_POST_TEXT
will ensure that it recognises the type and not ignore it.
3. When a recognised/supported POST content type is received the application callback will be called with the event type CAN_POST_BEGIN and the application level can decide whether it wants to accept (return 0) it or ignore it (return 1). Ignored posts will be silently discarded but the transfer is allowed to take place (to nowhere).
4. POST content is either saved to file or passed to the application (on a TCP frame basis).
Posts that are saved to file report success at the end with the callback event INFORM_POST_SUCCESS or INFORM_POST_FAILED.
Posts that are handled by the application layer pass each TCP frame's payload using the event POSTING_DATA_TO_APP and the application uses the content for whatever purpose it chooses - for example it can also save it to a file or interpret its content as it arrives. The final events INFORM_POST_SUCCESS or INFORM_POST_FAILED again signal the end of the complete post content.
5. Plain text post content is usually handled by POSTING_PARTIAL_PARAMETER_DATA_TO_APP and POSTING_PARAMETER_DATA_TO_APP event (POSTING_PARTIAL_PARAMETER_DATA_TO_APP indicates a fragment of a larger plain-text post and POSTING_PARAMETER_DATA_TO_APP indicates either a complete one in a single frame or the last in a larger post. This is typically used for passing parameters (like JSON strings) where the application will parse the content to extract the values (in the case of partial frames it may need to add buffering so that it can collect complete parameters before interpretation is possible).
See fnHandleWeb() in webInterface.c in the uTaskerV1.4 project for some reference handling of the events.
It is recommended to use the simulator to test such transfers, where a break point in fnHandleWeb() allows each event and accompanying data packet to be analysed.
Regards
Mark
Here are few additional tips about handling POST to a web server.
1. Use WireShark to view the POST that is being received to be sure that the type is known. For example if text based content is being received the POST header will contain the content type "text/plain".
2. Ensure that the type is supported by the HTTP server - for example
#define SUPPORT_POST_TEXT
will ensure that it recognises the type and not ignore it.
3. When a recognised/supported POST content type is received the application callback will be called with the event type CAN_POST_BEGIN and the application level can decide whether it wants to accept (return 0) it or ignore it (return 1). Ignored posts will be silently discarded but the transfer is allowed to take place (to nowhere).
4. POST content is either saved to file or passed to the application (on a TCP frame basis).
Posts that are saved to file report success at the end with the callback event INFORM_POST_SUCCESS or INFORM_POST_FAILED.
Posts that are handled by the application layer pass each TCP frame's payload using the event POSTING_DATA_TO_APP and the application uses the content for whatever purpose it chooses - for example it can also save it to a file or interpret its content as it arrives. The final events INFORM_POST_SUCCESS or INFORM_POST_FAILED again signal the end of the complete post content.
5. Plain text post content is usually handled by POSTING_PARTIAL_PARAMETER_DATA_TO_APP and POSTING_PARAMETER_DATA_TO_APP event (POSTING_PARTIAL_PARAMETER_DATA_TO_APP indicates a fragment of a larger plain-text post and POSTING_PARAMETER_DATA_TO_APP indicates either a complete one in a single frame or the last in a larger post. This is typically used for passing parameters (like JSON strings) where the application will parse the content to extract the values (in the case of partial frames it may need to add buffering so that it can collect complete parameters before interpretation is possible).
See fnHandleWeb() in webInterface.c in the uTaskerV1.4 project for some reference handling of the events.
It is recommended to use the simulator to test such transfers, where a break point in fnHandleWeb() allows each event and accompanying data packet to be analysed.
Regards
Mark