Thanks for your response.  I ended up following your advice and works
well.

My mistake on the jpeg content-type.

On Apr 24, 6:21 pm, Mike Orr <[email protected]> wrote:
> On Sat, Apr 24, 2010 at 4:35 PM, bstow01 <[email protected]> wrote:
> > I have written some custom middleware that is handy when serving HTML
> > pages.  Lately Ive created a controller that returns a dynamically
> > generated JPEG (content-type: text/jpeg) and my custom middleware
> > doesn't make any sense in the context of serving JPEG's (and it in
> > fact chokes on it).  Is there a way to simply leap frog over a certain
> > piece of middleware for certain controllers or routes? - or - maybe it
> > would be better to return early from my custom middleware based upon
> > some kind of condition that identifies the requests that will return
> > JPEGs?
>
> Normally the middleware itself would pass through content types it
> can't handle properly. But if it doesn't, and if it's not possible to
> modify the middleware (e.g., with a constructor arg that tells it
> which kinds of content to ignore), you could write a wrapper
> middleware that selectively invokes it or bypasses it. This would not
> be a straight middleware chain, but the wrapper would be in the chain,
> and it would invoke the custom middleware in the appropriate
> circumstances.
>
> app = MyWrapperMiddleware(app, MyCustomMiddleware, content_types=["text/*"])
>
>     if content_type in content_types:
>         body = self.custom_middleware(body)
>
> something like that.
>
> JPEG is not "text/jpeg" of course; it's "image/jpeg". That could be
> your problem if you're serving it as text/jpeg.
>
> --
> Mike Orr <[email protected]>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/pylons-discuss?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to