If I were to send out a HTTP GET request to e.g. the Shodan REST streaming API, is this implemented on the server side by periodically sending out HTTP Keep-Alive messages to the client in case there is no new data to be sent out?
Or are there other options/techniques available for implementing REST streaming API endpoints?
There is no such thing as an http keepalive message.
The API you link to simply doesn't tell the client in advance how long the response body is, so a client can keep reading the newline-separated messages from what counts as one response until either side decides they're done.
Related
Our application provides a REST API. However, a client can communicate only over TCP.
Is it possible in WSO2 ESB to make a proxy which would listen to TCP internally, then send the request to a REST API and send out the response as TCP?
The TCP request contains a message ID, which must be sent out in the response in order to be able to couple on the client-side.
You can use TCP transport receiver. Please refer the documentation for more details
API sends to my app message via http POST method.
To prevent data loss while my controller is off I want to use rabbit.
how to receive http POST requests in rabbitmq?
is possible at all?
No. There has to be some component which converts the requests. You also have to consider that the HTTP request requires a response. Do you respond with status 200/201 all the time, indicating "OK"/"Created"? What about errors you only discover later, when your controller is online again?
In your situation you might want to ask your users to send the data directly using RabbitMQ instead of using HTTP.
I read the Pika doc, but I am not quite understand why it says "AMQP a two-way RPC protocol, where the client can send requests to the server and the server can send requests to a client...". Can anyone give me an example please ?
Does it mean when we create a exchange.
client sends: exchange.declare
server replies: exchange.declare-ok
Are these two method requests?
In your particular example exchange.declare is client request and exchange.declare-ok is server response.
Though, there are some methods that server can send to client, e.g. basic.deliver, basic.return, connection.blocked (RabbitMQ-specific extension).
As I have a requirement to build a rest service in Message broker to receive the multipart request from mobile apps and just passthrough the request to backoffice system to store the attachments in repository.
And back office system store the attachment and will send the http response to Message broker, then again message will passthrough the response back to mobile apps.
But the request message contentType= 'multipart/form-data' for attachment
and response message contentType= 'application/Json-data' for the status updates back to client system
So is it possible to have a different content type for request for 'multipart' and response 'json-data' for the rest http service?
Thanks.
As long as your REST service accepts and has a handler to process the multipart/form-data then it won't be a problem. Some services for example will ignore a request if it isn't in XML or JSON, others will accept various types of formats.
So check your REST service for what format it can process.
As for the response, again, if the client has a header stating it accepts JSON, then you can send it JSON. This is more easier to check as the REST service can check the "Accept" header on the request to determine if the client is happy to receive JSON.
Many REST services check this to send commonly either JSON or XML back.
So to summarise, yes you can mix and match request/response types as long as both the client and service are happy to accept and handle the request/response types.
I'm implementing a REST service using WCF which will be used to upload very large files. The HTTP headers in this request will communicate information which will be validated prior to allowing the upload to proceed (things like permissions, available disk space, etc). It's possible this validation will fail resulting in an error response. I'd like to do this validation prior to the client sending the body of the request, so it has a chance to detect failure before uploading potentially gigabytes of data.
RESTful web services use the HTTP 1.1 Expect: 100-continue in the request to implement this. For example Amazon S3's REST API can validate your key and ACLs in response to an object PUT operation, returning 100 Continue if all is well, indicating you may proceed to send your data.
I've rummaged around the WCF documentation and I just can't see a way to accomplish this without doing some pretty low-level hooking into the HTTP request processing pipeline. How would you suggest I solve this problem?