How can I respond to an http get request with AppleScript results? - applescript

I have an AppleScript that produces JSON with which I would like to provide in response to an http get request.
[Update]:
I discovered the following on the MacScripter website. Question now is how to have the web server (MacOS Server’s Web Service specifically) invoke the AppleScript Handle CGI Request Handler with the arguments from the HTTP GET.
... In fact, the Standard Additions scripting addition, which is built
into Mac OS X, defines several command handlers.
One such handler is handle CGI request, which can be found within the
Internet suite in the Standard Additions dictionary. This command
handler can be used within a stay opened script application to process
CGI (Common Gateway Interface) requests from a web server.

Related

Can changing user agent to android in jmeter recorded test send traffic from android devices even if no emulator is installed in my laptop?

For load testing from different browser do we need to have all browser version on host machine or user agent change in existing script will work?
JMeter acts on protocol level, it builds HTTP requests using Java code and Apache HTTPClient libraries by default.
If application you're trying to test logic differs depending on browser you can mimic different browsers by sending the relevant User-Agent header via HTTP Header Manager.
Also consider the following settings:
configure your HTTP Request samplers to:
Retrieve all embedded resources
Use concurrent pool of 4-6 threads for this
This way you will be able to replicate browser behaviour when it comes to working with images, CSS files, JavaScript files, etc.
add HTTP Cache Manager to represent browser cache
add HTTP Cookie Manager to mimic simulate browser cookies, deal with cookie-based authentication, represent sessions, etc.
Check out How To Make JMeter Behave More Like A Real Browser guide for more detailed explanation of the above recommendations.
No.
A web-browser uses User-Agent to tell a server what kind of Browser and Operating System it uses. According to Wikipedia:
This allows the web site to customize content for the capabilities of a particular device
If you recorded your script with Chrome, JMeter would tell the server it was Chrome, and the server would respond to JMeter as if it were Chrome. JMeter, however, does not actually user Chrome in any way. Similarly, if you were to change you User-Agent to Android, the server would just respond to JMeter as if it were an Android device.

Does the built-in http server implement non-blocking I/O?

This is a first server-side swift framework available now. I am interested to use it for high traffic mobile app server.
Does this swift based framework implement the non-blocking I/O http server?
Yes, the internal networking in Perfect is all non-blocking. This is the case if you are doing raw TCP comms., using the built-in HTTP server or the FastCGI server. Check out the NetTCP and NetNamedPipe classes. They take callbacks when you connect, accept, read or write data. All of the relevant functions take a timeout parameter as well. You can optionally accept custom server connections in a blocking loop.
The individual web handlers are non-blocking as well in that you call a callback to tell the system that you are done with the request. The system will complete the current request and await others utilizing keep-alive.

How do I pass the response writer and http request to an executable in Go?

I want to run a simple webserver in Go doing some basic authorisation and routing to multiple apps.
Is it possible to have the webserver running as a standalone executable and pass the response writer and http request to other executables?
The idea is that the app binaries can hopefully be compiled and deployed independently of the webserver.
Memory areas of running applications are isolated: a process cannot just read or write another application's memory (Wikipedia: Process isolation).
So just passing the response writer and the http request is not so easy. And even if you would implement it (e.g. serializing them into binary or text data, sending/passing them over somehow, and reconstructing them on the other side) serving an HTTP request in the background is more than just interacting with the ResponseWriter and Request objects: it involves reading from and writing to the underlying TCP connection... so you would also have to "pass" the TCP connection or create a bridge between the real HTTP client and the application you forward to.
Another option would be to send a redirect back to the client (HTTP 3xx status codes) after doing the authentication and routing logic. With this solution you could have authentication and certain routing logic implemented in your app, but you would lose further routing possibilities because further request would go directly to the designated host.
Essentially what you try to create is the functionality of a proxy server which have plenty of implementations out there. Given the complexity of a good proxy server, it should not be feasible to reproduce one.
I suggest to either utilize an existing proxy server or "refactor" your architecture to avoid this kind of segmentation.

Real-time HTTP stream writing console

Is there a program available that will allow me to interactively write HTTP stream data and send it to a server? Ideally I'm looking for a console app that will allow me to type or paste HTTP headers and body, send it to my server, and get the response headers and body back.
Does such a program already exist?
I'm running W7 64-bit with .NET 4.0.
if you change your mind and want a GUI app
http://code.google.com/p/rest-client/
or you can also use fiddler
Edit:
http://code.google.com/p/rest-client/ also supports commandline
Maybe telnet is an option for you? If it's not already installed on your machine, take a look at this guide from MS.
To connect to your server use it like this:
telnet www.myserver.de 80
After the connection is established, you can paste your HTTP GET reqests or what ever you like.
tinyget is a useful MSFT tool that will make simple get requests. You can store these requests in text files and stream them in.

How to register your application into\with Http.sys?

So I created a TCP\HTTP server (IN C#). I want to give to it namespace on my 80's port near to other HTTP servers I have. How to do such thing (step - by step)?
Look at HTTP Server Tasks in MSDN spec:
Initialize HTTP service API, call HttpInitialize
Register URLs with HTTP.SYS, call HttpAddUrlToUrlGroup
Receive a request, call HttpReceiveHttpRequest
Send a response, call HttpSendHttpResponse
Cleanup after urself, call HttpRemoveUrl and HttpTerminate
There is a also a fully fledged application sample at HTTP Server Sample Application.
As you can clearly see, HTTP.SYS API is a C API intended for C applications. You shouldn't be using it from C#, and I'd recommend against pInvoking the entire API. Managed applications have the alternative of using HTTP modules and extend the ASP.Net processing. This avenue will take care of many details needed in a managed server, like activation, hosting, process monitoring and recycling and so on and so forth.
The way you would normally interact with http.sys is by registering an ISAPI DLL with IIS. This is a good starting-point.

Resources