Raw Post Callback 2pX
Overview
This is a NetBurner embedded web server application that demonstrates how to handle raw HTTP POST requests. The application creates a web server that can receive and process form data submitted through HTTP POST requests.
Application Components
Main Application (main.cpp)
- Application Name: "Raw Post Callback 2pX"
- Purpose: Initializes the network stack and starts an HTTP web server
- Key Features:
- Network stack initialization
- System diagnostics enabled
- HTTP server startup on default port 80
- DHCP network configuration with 5-second timeout
- Continuous operation loop
Form Handler (formcode.cpp)
- Purpose: Handles HTTP POST requests from web forms
- Key Features:
- Raw POST data processing with boundary marker support
- Real-time data streaming and display
- HTML response generation
- Buffer management for large POST data
- Multipart form data handling capability
Web Interface (index.html)
- Purpose: Provides a simple web form for user input
- Features:
- NetBurner logo display
- Single text input field
- Form submission to
post.html endpoint
- Clean HTML table-based layout
How It Works
- Initialization: The application starts by initializing the network stack and enabling system diagnostics
- Web Server: HTTP server starts on port 80
- Network Setup: Waits for DHCP to assign an IP address
- Form Display: Users can access the web interface to see the input form
- Data Submission: When users submit the form, data is sent via POST to
post.html
- Processing: The
RawPostCallBack function processes the POST data
- Response: The server responds with an HTML page showing the submitted data
Technical Details
POST Data Processing
- Uses
ReadSimpleBody() to read POST data in chunks
- Supports multipart form data with boundary markers
- Handles buffer overflow situations gracefully
- Displays received data in real-time during processing
Buffer Management
- File buffer size: 10,000 bytes
- Streaming data processing to handle large submissions
- Proper memory management for continuous operation
Network Configuration
- Default HTTP port: 80
- DHCP network configuration
- 5-second timeout for network activation
- Continuous monitoring loop with 1-second intervals
Usage
- Flash the application to a NetBurner device
- Connect the device to a network with DHCP
- Navigate to the device's IP address in a web browser
- Enter text in the form field and click "Submit"
- View the processed POST data in the response page
Development Environment
- Built for NetBurner 2pX platform
- Uses NetBurner NNDK (NetBurner Network Development Kit)
- Requires NetBurner development tools and libraries
Files
main.cpp - Main application entry point and initialization
formcode.cpp - HTTP POST request handler and form processing
index.html - Web interface with input form
Notes
- System diagnostics are enabled for debugging (should be disabled in production)
- The application runs continuously in a loop
- Shows practical implementation of embedded web server POST handling