Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:17:53+00:00 2026-06-13T13:17:53+00:00

I am building an event collector in Clojure for Snowplow (using Ring/Compojure) and am

  • 0

I am building an event collector in Clojure for Snowplow (using Ring/Compojure) and am having some trouble serving a transparent pixel with Ring. This is my code for sending the pixel:

(ns snowplow.clojure-collector.responses
  (:import (org.apache.commons.codec.binary Base64)
           (java.io ByteArrayInputStream)))

(def pixel-bytes (Base64/decodeBase64 (.getBytes "R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")))
(def pixel (ByteArrayInputStream. pixel-bytes))

(defn send-pixel
   []
    {:status  200
     :headers {"Content-Type"   "image/gif"}
     :body    pixel})

When I start up my server, the first time I hit the path for send-pixel, the pixel is successfully delivered to my browser. But the second time – and every time afterwards – Ring sends no body (and content-length 0). Restart the server and it’s the same pattern.

A few things it’s not:

  1. I have replicated this using wget, to confirm the intermittent-ness isn’t a browser caching issue
  2. I generated the "R01GOD..." base64 string at the command-line (cat original.gif | base64) so know there is no issue there
  3. When the pixel is successfully sent, I have verified its contents are correct (diff original.gif received-pixel.gif)

I’m new to Clojure – my guess is there’s some embarrassing dynamic gremlin in my code, but I need help spotting it!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:17:54+00:00Added an answer on June 13, 2026 at 1:17 pm

    I figured out the problem in the REPL shortly after posting:

    user=> (import (org.apache.commons.codec.binary Base64) (java.io ByteArrayInputStream))
    java.io.ByteArrayInputStream
    user=> (def pixel-bytes (Base64/decodeBase64 (.getBytes "R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==")))
    #'user/pixel-bytes
    user=> (def pixel (ByteArrayInputStream. pixel-bytes))
    #'user/pixel
    user=> (slurp pixel-bytes)
    "GIF89a!�\n,L;"
    user=> (slurp pixel-bytes)
    "GIF89a!�\n,L;"
    user=> (slurp pixel)
    "GIF89a!�\n,L;"
    user=> (slurp pixel)
    ""
    

    So basically the problem was that the ByteArrayInputStream was getting emptied after the first call. Mutable data structures!

    I fixed the bug by generating a new ByteArrayInputStream for each response, with:

        :body    (ByteArrayInputStream. pixel-bytes)}))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some trouble linking properly against libraries in C. I'm sure this is
I'm building a music events website and want to have a 'share this event'
I'm using backbone for an app that I'm building. In this app, I have
I am building a WebDAV server class library for .NET and I'm having some
I'm writing tools for building games in .NET using functional style. For this, I
I'm building an application that needs to fire an event every second, but it
I'm building an events listing site. Currently each event is entered for a specific
I'm building an application with a domain model using CQRS and domain events concepts
building a site using PHP and MySQL that needs to store a lot of
I am building a scala web project using scala test, lift, jpa, hibernate, mercurial

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.