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

The CFML Talent Crunch in 2025: Why Modernization Can’t Wait

The CFML Talent Crunch in 2025: Why Modernization Can’t Wait

How organizations can stay competitive when CFML expertise is harder to find than ever?

1. The Silent Crisis: CFML Talent Is Disappearing

For many organizations, ColdFusion and CFML applications still power critical business processes.

But there’s a growing challenge that leaders can no longer ignore:

The number of experienced CFML developers is shrinking—and it’s happening fast.

Why?

  • Few new devel...

Cristobal Escobar
Cristobal Escobar
December 09, 2025
CFCamp Pre-Conference Workshops led by Ortus Solutions!

CFCamp Pre-Conference Workshops led by Ortus Solutions!

We’re excited to announce the Pre-Conference Workshops for CFCamp 2026, Europe’s CFML-focused conference! Join us on June 16–17, 2026 at the Atomis Hotel Munich Airport by Mercure, Oberding for a deep dive into modern CFML and BoxLang development.

These workshops are the perfect opportunity to get hands-on training from the experts, level up your skills, and explore the future of CFML development before the main conference kicks off on June 18–19.

Maria Jose Herrera
Maria Jose Herrera
December 08, 2025