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

Introducing the BoxLang Spring Boot Starter: Dynamic JVM Templating for Spring

Introducing the BoxLang Spring Boot Starter: Dynamic JVM Templating for Spring

Spring Boot developers know the pain of evaluating view technologies. Thymeleaf is great — until you need more expressiveness. FreeMarker is powerful — until the syntax fights you. What if you could write templates in a dynamic JVM language that gives you the full power of the platform, feels natural, and requires zero setup to integrate?

Meet the BoxLang Spring Boot Starter.

Luis Majano
Luis Majano
March 13, 2026
Why Swiss Banks Are Modernizing CFML Platforms Without Rewrites

Why Swiss Banks Are Modernizing CFML Platforms Without Rewrites

The growing need to evolve legacy financial platforms safely

Many Swiss banks and financial institutions still operate important systems built on ColdFusion and CFML platforms.

These systems manage a wide range of functions, including:

  • internal banking workflows
  • reporting systems
  • client portals
  • data integration platforms
  • compliance and risk management tools

In many cases, thes...

Cristobal Escobar
Cristobal Escobar
March 13, 2026
Reactive vs Proactive ColdFusion Support: Why Waiting for an Outage Is the Most Expensive Strategy

Reactive vs Proactive ColdFusion Support: Why Waiting for an Outage Is the Most Expensive Strategy

Many ColdFusion environments operate in a reactive mode without realizing it.

Everything seems fine… until something breaks.

A server crashes.

Performance drops suddenly.

An integration stops working.

A security audit reveals missing patches.

At that point the response is urgent:

“Can someone help us fix this now?”

Emergency support is sometimes unavoidable. But when reactive intervention becomes the norm, it usually means something deep...

Cristobal Escobar
Cristobal Escobar
March 12, 2026