Skip to main content

Overview

The httpc command-line tool is a curl-like HTTP client that operates over the reliable UDP protocol. It supports GET and POST requests with headers, inline data, file uploads, and verbose output.

General Usage

httpc command [arguments]
All requests are sent through the reliable UDP protocol implementation, providing TCP-like reliability over UDP.

Commands

help

Displays usage information.
httpc help
httpc help get
httpc help post
httpc is a curl-like application but supports HTTP protocol only.
Usage:
    httpc command [arguments]
The commands are:
    get     executes a HTTP GET request and prints the response.
    post    executes a HTTP POST request and prints the response.
    help    prints this screen.

Use "httpc help [command]" for more information about a command.

GET Command

Executes an HTTP GET request for a given URL.

Syntax

httpc get [-v] [-h key:value] URL

Parameters

-v
flag
Verbose mode. Prints the detailed response including protocol, status, and headers.
-h
string
Associates headers to the HTTP request with the format key:value. Can be used multiple times.
URL
string
required
The target URL for the GET request. Must include protocol, host, and path.

Examples

httpc get http://httpbin.org/get

Response Format

Shows only the response body:
{
  "args": {},
  "headers": {
    "Host": "httpbin.org"
  },
  "url": "http://httpbin.org/get"
}

Help Text

httpc help get
usage: httpc get [-v] [-h key:value] URL

Get executes a HTTP GET request for a given URL.

    -v	Prints the detail of the response such as protocol, status, and headers.
    -h key:value	Associates headers to HTTP Request with the format 'key:value'.

POST Command

Executes an HTTP POST request for a given URL with inline data or file content.

Syntax

httpc post [-v] [-h key:value] [-d inline-data] [-f file] [-o output] URL

Parameters

-v
flag
Verbose mode. Prints the detailed response including protocol, status, and headers.
-h
string
Associates headers to the HTTP request with the format key:value. Can be used multiple times.
-d
string
Associates inline data to the body of the HTTP POST request.
-f
string
Associates the content of a file to the body of the HTTP POST request.
-o
string
Writes the response output to the specified file instead of stdout.
URL
string
required
The target URL for the POST request.
Either -d or -f can be used, but not both simultaneously.

Examples

httpc post -h Content-Type:application/json \
  -d '{"Assignment": 1}' \
  http://httpbin.org/post

Request Format

The POST command automatically constructs a proper HTTP request:
POST /post HTTPFC/1.0
Content-Type: application/json
Content-Length: 20

{"Assignment": 1}

Help Text

httpc help post
usage: httpc post [-v] [-h key:value] [-d inline-data] [-f file] URL

Post executes a HTTP POST request for a given URL with inline data or from file.

    -v	Prints the detail of the response such as protocol, status, and headers.
    -h key:value	 Associates headers to HTTP Request with the format 'key:value'.
    -d string	 Associates an inline data to the body HTTP POST request.
    -f file	Associates the content of a file to the body HTTP POST request

Either [-d] or [-f] can be used but not both.

Common Flags

Purpose: Display full response detailsBehavior:
  • Shows HTTP version and status code
  • Displays all response headers
  • Shows response body
Example:
httpc get -v http://httpbin.org/get
Output:
HTTPFC/1.0 200 OK
Content-Type: application/json
Content-Length: 256

{"response": "data"}
Purpose: Add custom HTTP headers to the requestFormat: -h key:valueUsage:
  • Can be specified multiple times
  • No spaces around the colon
  • Common headers: Content-Type, Authorization, Accept, User-Agent
Examples:
# Single header
httpc get -h Accept:application/json http://example.com

# Multiple headers
httpc post \
  -h Content-Type:application/json \
  -h Authorization:Bearer-token \
  -d '{"data":"value"}' \
  http://example.com/api
Purpose: Send inline data in POST request bodyPOST only: This flag is only valid for POST requestsUsage:
  • Mutually exclusive with -f
  • Automatically sets Content-Length header
  • String data is sent as-is
Examples:
# JSON data
httpc post -d '{"name":"John"}' http://example.com/api

# Form data
httpc post -d 'name=John&[email protected]' http://example.com/form

# With explicit content type
httpc post \
  -h Content-Type:application/json \
  -d '{"user":{"name":"John"}}' \
  http://example.com/api
Purpose: Send file contents in POST request bodyPOST only: This flag is only valid for POST requestsUsage:
  • Mutually exclusive with -d
  • Reads entire file into request body
  • File path is relative to current directory
Examples:
# Send JSON file
httpc post -f request.json http://example.com/api

# Send with headers
httpc post \
  -h Content-Type:application/json \
  -f data.json \
  http://example.com/api

# Verbose with file
httpc post -v -f payload.txt http://example.com/upload
Purpose: Write response to a file instead of stdoutUsage:
  • Works with both GET and POST
  • Creates or overwrites the specified file
  • File path is relative to current directory
Examples:
# Save GET response
httpc get -o response.json http://api.example.com/data

# Save POST response
httpc post -d '{"query":"test"}' -o result.txt http://example.com/api

# Verbose mode with file output
httpc get -v -o output.html http://example.com/page

URL Format

URLs must follow this format:
http://host:port/path
protocol
string
required
Must be http://
host
string
required
Hostname or IP address
port
number
required
Port number (no default)
path
string
Request path (defaults to /)

URL Examples

# With port
http://localhost:8080/api/data

# With IP address
http://192.168.1.100:8000/index.html

# With query parameters
http://example.com:8080/search?q=test&limit=10

HTTP Protocol

The client uses a custom HTTP/1.0-like protocol:
The protocol identifier is HTTPFC/1.0 instead of standard HTTP/1.0

Request Format

GET /path HTTPFC/1.0
Header1: value1
Header2: value2

POST /path HTTPFC/1.0
Header1: value1
Content-Length: 15

{"data":"test"}

Connection Process

1

Three-way handshake

The client establishes a reliable connection using SYN, SYN-ACK, ACK packets.
2

Request transmission

The HTTP request is chunked and sent using the Selective Repeat protocol.
3

Response reception

The client receives response packets, sends ACKs/NACKs, and assembles the complete response.
4

Connection closure

The connection is closed after the response is fully received.

Error Messages

malformed URL
Cause: Invalid URL format or missing componentsSolution: Ensure URL follows the format http://host:port/path
Wrong command
Cause: Command doesn’t start with httpcSolution: Start command with httpc followed by get, post, or help
Exceptions during socket operationsPossible causes:
  • Server not reachable
  • Network timeout
  • Port unavailable
Solution: Verify server is running and network connectivity

Integration Example

Using the httpc client programmatically:
import client.Httpc;
import util.Response;

public class Example {
    public static void main(String[] args) {
        Httpc client = new Httpc();
        
        try {
            // Execute GET request
            String cmd = "httpc get -v http://httpbin.org:80/get";
            Response response = client.getResponse(cmd);
            
            System.out.println("Status: " + response.getStatus());
            System.out.println("Code: " + response.getCode());
            
            if (response.getInFile()) {
                // Response was written to file
                System.out.println("Output written to: " + response.getFile());
            } else {
                // Print response body
                System.out.println(response.getBody());
            }
            
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

See Also

ReliableClientProtocol

Underlying reliable UDP protocol

Packet Format

Packet structure used for transmission

Build docs developers (and LLMs) love