
Nanofish
A lightweight, no_std HTTP client for embedded systems built on top of Embassy networking.
Nanofish provides a simple HTTP client implementation that works on constrained environments with no heap allocation, making it suitable for microcontrollers and other embedded systems. It supports all standard HTTP methods and provides a clean async API for making HTTP requests.
Features
- Full
no_stdcompatibility with no heap allocations - Built on Embassy for async networking
- Support for all standard HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE, CONNECT)
- Intelligent response body handling (automatic text/binary detection)
- Convenient header creation with pre-defined constants and methods
- Automatic handling of common headers
- DNS resolution
- Timeout handling and retries
- Optional TLS/HTTPS support (disabled by default)
Feature Flags
tls: Enables TLS/HTTPS support viaembedded-tls. When disabled (default), only HTTP requests are supported and HTTPS requests will return an error.
To use nanofish with HTTP only (default):
[]
= "0.4.0"
To use nanofish with TLS/HTTPS support:
[]
= { = "0.4.0", = ["tls"] }
Example
use ;
use Stack;
async
Header Convenience Features
Nanofish provides convenient ways to work with common HTTP headers:
Pre-defined Header Constants
use headers;
// Common header names
let content_type = CONTENT_TYPE; // "Content-Type"
let authorization = AUTHORIZATION; // "Authorization"
let user_agent = USER_AGENT; // "User-Agent"
let accept = ACCEPT; // "Accept"
Pre-defined MIME Types
use mime_types;
// Common MIME types
let json = JSON; // "application/json"
let xml = XML; // "application/xml"
let text = TEXT; // "text/plain"
let html = HTML; // "text/html"
Convenience Methods
// Easy creation of common headers
let headers = ;
Response Handling
Nanofish automatically determines the appropriate response body type based on the Content-Type header:
// The response body is automatically parsed based on content type
match &response.body
// Convenience methods for response analysis
if response.is_success
if response.is_client_error
if response.is_server_error
// Easy access to common headers
if let Some = response.content_length
Convenience Methods
Nanofish provides convenience methods for all standard HTTP verbs:
// GET request
let response = client.get.await?;
// POST request with JSON body
let json_body = b r#"{"name": "John", "email": "john@example.com"}"#;
let post_headers = ;
let response = client.post.await?;
// PUT request
let response = client.put.await?;
// DELETE request
let response = client.delete.await?;
// Other methods
let response = client.patch.await?;
let response = client.head.await?;
let response = client.options.await?;
All methods return a Result<HttpResponse, Error> and support the same header and response handling features.
License
The MIT License (MIT) Copyright © 2025 rttf.dev
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.