Blog

Luis Majano

December 09, 2025

Spread the word


Share your thoughts

New in BoxLang 1.8.0 - Say goodbye to verbose HTTP request building. BoxLang introduces a powerful fluent HTTP API that makes working with HTTP/S requests not just easier, but actually enjoyable.

Why This Changes Everything

BoxLang 1.8.0 introduces the http() BIF - a modern, chainable interface that transforms how you build HTTP requests. Gone are the days of juggling multiple configuration steps. Now you write requests the way you think about them:

// Clean, readable, powerful
result = http( "https://api.github.com/repos/ortus-boxlang/boxlang" )
    .header( "Accept", "application/json" )
    .userAgent( "BoxLang-App/1.0" )
    .timeout( 30 )
    .asJSON()  // Auto-parse response!
    .send()

println( result.name )  // Direct access to parsed data

The Power of Fluency

Built-in Response Transformers

Stop manually parsing responses. BoxLang does it for you:

// JSON response? Parse it automatically
userData = http( "https://api.example.com/users/123" )
    .asJSON()
    .send()

// XML? No problem
xmlDoc = http( "https://api.example.com/data.xml" )
    .asXML()
    .send()

// Plain text
content = http( "https://example.com/readme.txt" )
    .asText()
    .send()

Conditional Request Building

Build dynamic requests with elegant conditional logic:

httpClient = http( "https://api.example.com/data" )

// Add auth only if token exists
httpClient.ifNotNull( authToken, ( req ) => {
    req.header( "Authorization", "Bearer " & authToken )
} )

// Admin-specific headers
httpClient.when( userIsAdmin, ( req ) => {
    req.header( "X-Admin-Token", adminToken )
} )

// Default timeout if none specified
httpClient.ifNull( customTimeout, ( req ) => {
    req.timeout( 30 )
} )

result = httpClient.send()

REST Made Ridiculously Simple

HTTP method shortcuts make REST APIs a breeze:

// GET request (default method)
users = http( "https://api.example.com/users" ).send()

// POST with JSON body
newUser = http( "https://api.example.com/users" )
    .post()
    .jsonBody( '{"name":"John","email":"john@example.com"}' )
    .send()

// PUT to update
updated = http( "https://api.example.com/users/123" )
    .put()
    .body( { name: "Jane Doe" } )
    .send()

// DELETE
http( "https://api.example.com/users/123" )
    .delete()
    .send()

Real-Time Streaming with SSE

BoxLang natively supports Server-Sent Events for real-time data. Integrate with AI LLMs natively and easily:

function processEvent( event, lastEventId, httpResult, httpClient, response ) {
    println( "Event: " & event.event )
    println( "Data: " & event.data )
}

// Consume live event stream
http( "https://api.example.com/events" )
    .header( "Accept", "text/event-stream" )
    .onChunk( processEvent )
    .send()

Async by Default

Need non-blocking requests? BoxLang integrates seamlessly with Box Futures (https://boxlang.ortusbooks.com/boxlang-framework/asynchronous-programming):

// Fire and forget
boxFuture = http( "https://api.example.com/data" )
    .sendAsync()

// Process when ready
boxFuture.then( ( result ) => {
    println( "Got data: " & result.fileContent )
} )

Advanced Features That Just Work

Lifecycle Callbacks

Monitor and control the entire request lifecycle:

function handleRequestStart( httpResult, httpClient ) {
    println( "Starting request..." )
}

function handleChunk( chunk, lastEventId, httpResult ) {
    println( "Received: " & chunk.data.len() & " bytes" )
}

function handleComplete( httpResult ) {
    println( "Request completed: " & httpResult.statusCode )
}

function handleError( error, httpResult ) {
    println( "Error occurred: " & error.message )
}

http( "https://api.example.com/large-file" )
    .onRequestStart( handleRequestStart )
    .onChunk( handleChunk )
    .onComplete( handleComplete )
    .onError( handleError )
    .send()

File Uploads Made Simple

Multipart form data has never been easier:

http( "https://api.example.com/upload" )
    .post()
    .multipart()
    .file( "document", "/path/to/file.pdf" )
    .formField( "description", "Important document" )
    .formField( "category", "reports" )
    .send()

Enterprise-Ready Configuration

result = http( "https://api.example.com/data" )
    .connectionTimeout( 30 )
    .httpVersion( "HTTP/2" )
    .redirect( true )
    .proxyServer( "proxy.company.com", 8080 )
    .clientCert( "/path/to/cert.p12", "password" )
    .throwOnError( true )  // Auto-throw on 4xx/5xx
    .send()

The Bottom Line

BoxLang's HTTP API isn't just syntactic sugar - it's a fundamental rethinking of how HTTP requests should work in a modern language. With:

  • 🎯 Intellisense-friendly method names
  • âš¡ Async execution out of the box
  • 📡 Native SSE support
  • 🚀 Built-in transformers
  • 🎨 Conditional building
  • 🔧 HTTP/2 by default

You get enterprise-grade HTTP capabilities with developer-first ergonomics.

Ready to experience the future of HTTP in the JVM?

Get started with BoxLang today: boxlang.io

Add Your Comment

Recent Entries

MatchBox and WebAssembly: Running BoxLang in the Browser and at the Edge

MatchBox and WebAssembly: Running BoxLang in the Browser and at the Edge

The MatchBox open beta is live at https://boxlang.ortusbooks.com/boxlang-framework/matchbox, and it brings something genuinely new to the BoxLang ecosystem: a path into WebAssembly.

That means BoxLang code can now move into browser applications, static-site deployments, edge runtimes, and WASI-style containers - without requiring a JVM. The feature is still beta, but the core direction is already useful: write BoxLang, compile it with MatchBox, and ship the generated WASM artifact to wherever a small portable runtime makes sense.

Jacob Beers
Jacob Beers
June 04, 2026