Skip to main content
The httpc client is a curl-like HTTP client that supports GET and POST requests using the Selective Repeat UDP protocol.

Getting Started

1

Start the Router

Before using the client, ensure the router is running:
./router --port 3000
2

Run the Client

Launch the client application:
cd Client
mvn exec:java -Dexec.mainClass="client.CLient"
You’ll see a prompt: Enter your command..
3

Execute Commands

Enter httpc commands at the prompt. See examples below.

Command Structure

The basic syntax for httpc commands is:
httpc command [options] URL
All commands must start with httpc. The URL must include the port number used by your server.

Help Command

Get help information about available commands:
httpc help

Help Output

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 Requests

Perform HTTP GET requests to retrieve data from the server.

Basic GET Request

httpc get http://localhost:8080/get
The URL path /get is a common endpoint for testing GET requests.

GET with Query Parameters

Query parameters are automatically appended to the /get path:
httpc get http://localhost:8080/get?name=John&age=30

Verbose Mode

Use the -v flag to see detailed response information including headers:
httpc get -v http://localhost:8080/get
Verbose mode shows the HTTP protocol version, status code, and all response headers.

GET with Custom Headers

Add custom headers using the -h flag:
httpc get -h Authorization:Bearer-token123 http://localhost:8080/get

Multiple Headers

Include multiple headers by repeating the -h flag:
httpc get -h Content-Type:application/json -h Accept:application/json http://localhost:8080/get

Complete GET Example

httpc get -v -h User-Agent:httpc/1.0 -h Accept:application/json http://localhost:8080/get?query=test

POST Requests

Send data to the server using HTTP POST requests.

POST with Inline Data

Use the -d flag to send inline data:
httpc post -d '{"name":"John","age":30}' http://localhost:8080/post
The client automatically adds a Content-Length header based on the data size.

POST with Data from File

Use the -f flag to read data from a file:
httpc post -f data.json http://localhost:8080/post
Either -d or -f can be used, but not both simultaneously.

POST with Headers

Add custom headers to POST requests:
httpc post -h Content-Type:application/json -d '{"key":"value"}' http://localhost:8080/post

Verbose POST

See detailed response information:
httpc post -v -d 'test data' http://localhost:8080/post

Complete POST Example

httpc post -v -h Content-Type:application/json -h Authorization:Bearer-xyz -d '{"message":"Hello World"}' http://localhost:8080/post

Output Options

Write Response to File

Use the -o flag to save the response to a file:
httpc get -o output.txt http://localhost:8080/get
This is useful for saving large responses or when you need to process the output later.

Console Output

By default, responses are printed to the console. Without verbose mode, only the response body is shown:
httpc get http://localhost:8080/get
With verbose mode, headers and status are included:
httpc get -v http://localhost:8080/get

Command Options Reference

-v, --verbose
flag
Prints detailed response information including protocol, status, and headers.
-h, --header
string
Associates headers to the HTTP request in the format key:value. Can be used multiple times.
-d, --data
string
Associates inline data to the HTTP POST request body. Cannot be used with -f.
-f, --file
string
Reads data from a file for the HTTP POST request body. Cannot be used with -d.
-o, --writeinfile
string
Writes the response to the specified file instead of printing to console.

Connection Flow

When you execute a command, the client:
1

Establishes Connection

The client connects to the server through the router using a three-way handshake.
Connecting to server
2

Sends Request

Once connected, the request is sent using the Selective Repeat protocol.
Connection established, sending request
3

Receives Response

The client receives the response packets and reassembles them.
Received Response
4

Displays Output

The response is parsed and displayed according to the specified options.

Real-World Examples

Test a JSON API endpoint:
httpc get -v -h Content-Type:application/json -h Accept:application/json http://localhost:8080/get?id=123

Interactive Mode

The client runs in interactive mode, allowing multiple requests:
mvn exec:java -Dexec.mainClass="client.CLient"
Enter your command..
httpc get http://localhost:8080/get
[Response displayed]
do you want to continue?
yes
Enter your command..
httpc post -d 'test' http://localhost:8080/post
[Response displayed]
do you want to continue?
no
Type “yes” to continue making requests or “no” to exit the client.

Troubleshooting

Ensure the router and server are running:
# Terminal 1: Start router
./router --port 3000

# Terminal 2: Start server
cd Server
mvn exec:java -Dexec.mainClass="Server.ServerCommand"
httpfs -p 8080
Make sure your URL includes the protocol and port:
# Correct
httpc get http://localhost:8080/get

# Incorrect
httpc get localhost/get
When using -f, ensure the file path is correct:
# Use absolute or relative path
httpc post -f ./data.json http://localhost:8080/post
httpc post -f /home/user/data.json http://localhost:8080/post
Use the correct format for headers (no spaces around colon):
# Correct
httpc get -h Content-Type:application/json http://localhost:8080/get

# Incorrect
httpc get -h Content-Type: application/json http://localhost:8080/get

Next Steps

Server Setup

Learn how to set up the httpfs server

Router Configuration

Configure network conditions for testing

Build docs developers (and LLMs) love