Arc Forumnew | comments | leaders | submitlogin
POST requests in Arc
3 points by hjek 806 days ago | 5 comments
https://github.com/arclanguage/anarki/issues/25


4 points by aw 805 days ago | link

Arc handles HTTP requests character by character, which is fine for form submits or REST APIs, but not what you want for handling large binaries.

To be able to handle image uploads directly in Arc, you'd want an HTTP server implementation which supported binary buffers.

But, not everything needs to be implemented directly in Arc. Instead you could use e.g. Ngnix or Apache to handle the image uploads, or upload the images directly to AWS S3 from the browser.

-----

2 points by hjek 804 days ago | link

Interesting! Arc is reading the request one character at the time. I think I see where it's happening, in the handle-request-thread function where readc is called. So, for Nginx/Apache, are you suggesting Arc might be able to handle uploads if it's sitting behind Nginx/Apache acting as reverse proxy doing buffering? Or is it more like doing anything with big files in Arc is a no-go, so it's better to have a separate setup of Nginx/Apache (with PHP or whichever) handling file the uploads?

-----

3 points by aw 803 days ago | link

> So, for Nginx/Apache, are you suggesting Arc might be able to handle uploads if it's sitting behind Nginx/Apache acting as reverse proxy doing buffering?

Nope, that won't help.

> so it's better to have a separate setup of Nginx/Apache (with PHP or whichever) handling file the uploads

That's the easiest approach. Not that you'd need PHP, just pop in a module to handle file uploads for you.

> Or is it more like doing anything with big files in Arc is a no-go

Not Arc as such but the implementation in srv.arc isn't designed for large files. You could read the old MZScheme documentation at http://docs.racket-lang.org/mzscheme/index.html and figure out how to read an input stream into a binary buffer, but it would be more work.

-----

1 point by hjek 801 days ago | link

Thanks a lot for helping clear that up. Those limitations of Arc are definitely not immediately obvious from reading the docs and essays available on the language.

-----

2 points by hjek 806 days ago | link

I love Arc as a language. A friend asked me to set up a web board for artists, so I thought it would be nice to work in Arc, and extend news.arc (instead of just using PHP or whatever) with some basic functionality for handling small-to-medium sized images (<1MB per image). However Arc 3.1 (and Rainbow and Anarki) seem to choke on POST requests larger than ~100KB, and become unresponsive afterwards. Would there be some other, more arcish way handling files over network?

-----