question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

binary output for regular web requests

See original GitHub issue

Describe the feature I’m looking at porting some web services from SparkJava to Javalin. The catch is that some of these services return generated image types (PNG, etc.). In SparkJava, you can say response.type("image/png"); return imageBytes;, but there’s no equivalent in Javalin to just take a raw array of bytes and emit them as the HTTP response body.

Additional context To some extent, all you need is a result(byte[]) in addition to the present result(String) method. I suppose you could have an image(BufferedImage) method that deals with the java.awt.BufferedImage class, figuring out the appropriate content type automatically.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
danwallachcommented, Jan 10, 2020

Sure, I’ll build something.

0reactions
danwallachcommented, Jan 10, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending and Receiving Binary Data - Web APIs | MDN
Receiving binary data in older browsers ... The loadBinaryResource() function shown below loads binary data from the specified URL, returning it ...
Read more >
binary output for regular web requests · Issue #849 · javalin ...
I'm looking at porting some web services from SparkJava to Javalin. The catch is that some of these services return generated image types...
Read more >
Working with binary media types for REST APIs
In API Gateway, the API request and response have a text or binary payload. ... is a list of content types that your...
Read more >
Binary data - HTTPie 3.2.1 (latest) docs
Binary data is suppressed for terminal output, which makes it safe to perform requests to URLs that send back binary data. Binary data...
Read more >
Python HTTP Request Binary Data using Requests
The curl -d switch sends a POST request, but you are using requests.get() instead, sending a GET request (whose body is ignored).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found