Forum Discussion

Craig_Jackson_1's avatar
Craig_Jackson_1
Icon for Nimbostratus rankNimbostratus
May 22, 2006

Responding with binary image

I'm trying to implement a "goaway" capability. It seems like it should be possible to implement it totally in the Bigip. Basically, I need to respond to all URLs with an HTML page saying "come back later". But they want a logo on the page.

 

 

I've got an iRule that looks like this:

 

 

when HTTP_REQUEST {

 

set content [b64decode "base 64 encoded PNG"]

 

HTTP::Respond 200 content $content "Content-Type" "image/png"

 

}

 

 

But it only sends the PNG up until the first null character, which is about 7 bytes. I also tried to add a content-length header using [string length $content], and also got a value of 7.

 

 

Is there any way to deal with binary data like this in iRules? HTTP::Payload replace perhaps?

 

 

Craig Jackson

 

Craig.Jackson@thomson.com

4 Replies

  • I know my full rule will need to include the html. What I expect to code is:

     

     

    if (URL is the image URL) {

     

    respond with the image contents

     

    } else {

     

    respond with go-away HTML, which references the image URL

     

    }

     

     

    What I'm trying to avoid is having an entire HTTP server (redundant for high availability, of course) sitting around just to serve up on 1500 byte PNG image in emergencies. (I could rely on some of my existing servers, of course, but that assumes that the problem doesn't lie with any of them.)

     

     

    The referenced iRule still relies on some other HTTP server to serve up the .wav file.

     

     

    Craig
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    Craig you are not doing any thing wrong, but instead I think you might be running into some Encoding issues we have seen with TCL. If you open a case with support we will try to get it figured out.

     

     

    But in the mean time, you might be able to get around this using some "poor man's" respond rule *if* you are not terminating the connection over SSL. If that is the case, please see this posting for an example on how to respond using the TCP::respond rule.

     

    Click here
  • Thanks. It looks like TCP::Respond works where HTTP::Respond fails, when null bytes are an issue.
  • Thread resurrection: :-)

     

     

    Hi Craig,

     

     

    Would you mind posting your TCP::respond version? I'm trying to accomplish a similar task and would like to see if we can return a page with an image using this method.

     

     

    Thanks!

     

     

    Denny