I'm working within the context of RPG Maker VX Ace. It has some Ruby extensions, and it has a subset of the Ruby 1.8 library built in. It also allows me to add my own .rb files -- such as the Ruby 1.9.3 source files -- albeit that I cannot use any code that has C extensions. If it requires a .so file, it won't work -- I'll get an error that "this application cannot load extensions/plugins."
Having understood this, I need some way to make an HTTP request. What I mean is:
- Call a URL (eg. http://myserver.com/blah?data=abcd
- Return the response (which will be a string -- not full HTML, just an identifier of some sort)
I have tried using open-uri
and net/http
. Both of them have different issues that prevent me from using. One (I think it's the latter) requires TcpSocket
, which is implemented in C and is not "pure" Ruby. The other one gives me an error about an undefined constant related to sockets.
I've also tried using the Socket
class, and it gives me a similar error.
TLDR: Is there some way I can make a Ruby HTTP call with pure Ruby, no C extensions? That is what I need.
I solved this by writing some code and calling it from Ruby. Easy breezy.
Using .NET, I created a non-command-line, non-service application; something which I can invoke like a command-line app, but without the command-line window. To do this:
When you run your project, it'll run like any command-line project (args, etc.) but no windows will appear.
From there, it was easy to make an asynchronous HTTP request and store the response in a text file. This is sufficient for now.
You could call out to a shell and execute curl (depending on your environment and the speed you want)
The -s makes curl silent. See if that stops the dos box coming up.