RubyMotion/BubbleWrap blocking HTTP requests support - rubymotion

I was looking at BubbleWrap HTTP support which seems to make aync requests. Is there way to make blocking HTTP requests using BubbleWrap or something else in RubyMotion.?
This is needed for HTTP requests where I am expecting a response that needs to be reported to the user.

I think you can call NSData::dataWithContentsOfURL

Related

Choosing the scenario of using Web Sockets in standard HTTP REST API

I will be happy to get advice from more experienced developers about adding Web Sockets into my HTTP-based project.
That’s the thing. I have developed the REST API based service. Everything works well enough, but… In some special cases my server needs a long time to serve client requests. It may be from 1 minute to several hours (and even days)! I implement some not-so-good algorithm to address this issue:
Client sends HTTP request
Server replies about registering request
Client starts sending HTTP requests to get necessary data (if response does not have needed information the client sends another request and so on)
That is all in a nutshell.
And it seems to be a bad scenario and I am trying to integrate web sockets for adding duplex-channels in this architecture. I hope that my API will be able to send info about updated data as soon as possible without the necessity of many requests from the client.
But I am a bit confused in choosing one of two ways to use web socket (WS).
Variant A.
The server only tells the client via WS that data is ready. And the client gets data by standard request-response HTTP method from REST API.
Variant B.
The server sends all data to the client via WS without HTTP at all.
What variant is more suitable? Or maybe some other variants?
I do not want to remove HTTP at all. I just try to implement WS for a particular kind of end-points.
Variant A would be more suitable and easy to implement. You can send message to the client after the data is ready, and he can then send request for the data. It will be like a simple chat websocket, and will serve your purpose.

How can I send HTTP broadcast message with tornado?

I have a tornado HTTP server.
How can I implement broad-cast message with the tornado server?
Is there any function for that or I just have to send normal HTTP message all clients looping.
I think if I send normal HTTP message, the server should wait for the response.
It seems not the concept of broad-cast.
Otherwise, I need another third-part option for broad-cast?
Please give me any suggestion to implement broad-cast message.
Short answer: you might be interested in WebSockets. Tornado seems to have support for this.
Longer answer: I assume you're referring to broadcast from the server to all the clients.
Unfortunately that's not doable conceptually in HTTP/1.1 because of the way it's thought out. The client asks something of the server, and the server responds, independently of all the others.
Furthermore, while there is no request going on between a client and a server, that relationship can be said to not exist at all. So if you were to broadcast, you'd be missing out on clients not currently communicating with the server.
Granted, things are not as simple. Many clients keep a long-lived TCP connection when talking to the server, and pipeline HTTP requests for it on that. Also, a single request is not atomic, and the response is sent in packets. People implemented server-push/long-polling before WebSockets or HTTP/2 with this approach, but there are better ways to go about this now.
There is no built-in idea of a broadcast message in Tornado. The websocket chat demo included with Tornado demonstrates how to loop over the list of clients sending a message to each:
def send_updates(cls, chat):
logging.info("sending message to %d waiters", len(cls.waiters))
for waiter in cls.waiters:
try:
waiter.write_message(chat)
except:
logging.error("Error sending message", exc_info=True)
See https://github.com/tornadoweb/tornado/blob/master/demos/websocket/chatdemo.py

Which HTTP Method is used to send SOAP messages?

Which HTTP Method is used to send SOAP messages?
I guess, if you are working at the servlet level,you could define the HTTP method(would there still be restrictions?).
But if all that is hidden, and I'm using a simple JAX WS webservice, which HTTP method would(should??) the request and response messages have?
I think JAX-WS and most other implementations use post for transmitting requests
you can verify it by capturing the request in TCP IP monitor

Making HTTP request from an apache2 module (c++)

My apache2 module written in c++ works just fine, it handles "page.xyz"-like requests from browser clients, and it can return the appropriate result.
What I need now is to use my module as a client to another server: make a HTTP (GET) request and get the response (GET https://graph.facebook.com/oauth/access_token?...).
Does apache has a magic can do this, or do I have to deal with sockets and make HTTP packets manually? What is the best way to do this?
Many thanks!
I am guessing you are on your own with the HTTP client. Probably the easiest way to make an HTTP connection is to use libcurl. On linux it should be installable from your distro's repositories.

SOAP request over HTTP delay

I am trying to send a SOAP request over HTTP for a web service through the following channels:
Telnet (HP-UX)
C client that opens a socket, writes XML and reads reasponse(HP-UX)
Perl client that does the same thing as the C client above(HP-UX)
Through SOAP UI application (http://www.soapui.org/)(Windows Machine)
While SOAP UI gets a response in about 100ms seconds or so; the rest of the channels get the same response but very slow.
I am wondering what might be the problem. If anybody has any idea about this please let me know.
Possibly the connection stays open per default for subsequent requests (not uncommon for webservers which expect you to request all kinds of javascript files, images, css files directly afterwards). You might want to try to send the Connection: close header.
Check the protocol , may be you are using HTTP1.0 not HTTP1.1