How to Send and Receive HTTP Requests and Response in BlackBerry? - blackberry

I don't know how to make Http connection with HTTP server using blackberry. I want to send argument with URL and I have to get a response from the server using Http connection I don't how to do this.pls provide me with some code snippet to handle this situation.

Related

Twilio MMS wont send video. I keep getting error Error - 11200

I am linking this file for my media URL:
my goal is for this to be sent as a MMS. I first had a file size error. I fixed that, now I am stuck with this error.
The video will play on my browser. But not on my phone, but it will play on my laptop.
Does anyone have any ideas what I might be doing wrong?
HTTP retrieval failure: Attempt to retrieve media failed. Possible
Causes Web server returned a 4xx or 5xx HTTP response to Twilio
Misconfigured Web Server Network disruptions between Twilio and your
web server No Content-Type header attached to response Content-Type
doesn't match actual content, e.g. an MP3 file that is being served
with Content-Type: audio/x-wav, instead of Content-Type: audio/mpeg
Possible Solutions Double check that your TwiML URL does not return a
4xx or 5xx error Make certain that the URL does not perform a 302
redirect to an invalid URL Confirm the URL requested is not protected
by HTTP Auth Make sure your web server allows HTTP POST requests to
static resources (if the URL refers to .xml or .html files) Verify
your web server is up and responsive Check to see that the URL host is
not a private or local IP address Verify the ping times and packet
loss between your web server and www.twilio.com
Error Description There was a failure attempting to retrieve the
contents of this URL. An 11200 error is an indicator of a connection
failure between Twilio and your service. When Twilio requests a page
from your server, we wait a maximum of 15 seconds for a response. A
connection failure will occur if no response is returned in that time.
There are many reasons a connection timeout can occur; common causes
are long running database queries or outside processes and calls to
external systems taking a long time to return. It may be possible your
application experienced one of these issues. If you are encountering
this error only intermittently, it is possible that your web server
was temporarily unavailable or experiencing a network outage. 502 Bad
Gateway errors If your debugger is reporting a 502 Bad Gateway error,
this may mean that Twilio's internal server had trouble retrieving
content from your website. Your request must contain a Content-Type
that is valid. Twilio may also have had problems resolving your DNS
name to an IP address, or issues with the network connection. Check
that your web server is started, and is available over the public
Internet.
Request Inspector
+ Expand All
GET https://meetlete.com/media/small-met.mp4 2021-02-21 05:05:07 UTC404 Request URL Parameters Message TextShow Raw
Msg "Attempt to retrieve media failed."
httpResponse "404"
EmailNotification "false"
url "https://meetlete.com/media/small-met.mp4"
LogLevel "ERROR"
Twilio developer evangelist here.
It might be the case that Twilio cached a 404 response to your video at some point. I just tried sending a media message using your URL and it was processed correctly and the video was ingested by Twilio.
I would advise you try again. If you still find that your account has cached the URL response, you could try moving the video to a different address and trying with that instead.

Rails. using a web socket like rest, but with an open connection

I have a web api that posts json to different external endpoints on certain conditions. We have a new client that wants us to open a web socket connection with them during an event, send them the data (json) when we get it via this socket, and close the socket after the event. I'm having a hard time figuring out the rails way to do this.
How do I open a web socket connection and keep it open? (basically where would the client sit/ what would the definition look like).
How do I send messages over the socket from a controller? (eg. after processing a post request send new data to this websocket)
How do I close the connection?
You can try using this gem called Faye. Here's an example for connecting and sending data: (note: I didn't test it)
# Open the connection
ws = Faye::WebSocket::Client.new('ws://www.example.com/')
# Send data to connection
ws.send(YOURJSONDATA)
# Close connection (RFC 6455)
ws.close
Notes for faye:
Using the WebSocket client
Adding headers and other options to connection
WebSocket API
RFC 6455
Hope it helps!

Get HTTP Status-Line in Alamofire

I am using the Alamofire 4.0.1 library in swift 3; I am looking for the HTTP Status-Line (as described in https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html). I can get the status code, the headers, everything, but not the status message.
I am querying a REST API which gives me 403 responses with different messages after the "Forbidden" keyword describing the problem: like the client is not approved for access or that accessing an specific URL is not allowed, because it is for internal use only. In my client accessing the API I want to give the user more details than just the "Forbidden" message.
This is what the server sends back (I know this because I used Paw, a HTTP Client to send a HTTP request and investigate the response):
HTTP/1.0 403 Forbidden (internal method)
So to conclude, is there any chance to get the HTTP Status-Line in Alamofire?
Unfortunately no
Alamofire uses the URLResponse and it does not implement any field/method that gives you information about Status-Line. To get the Status-Line you should use other maybe lower-level frameworks.
URLResponse gives you only information about allHeaderFields, you can look on my answer about it here :
https://stackoverflow.com/a/36524454/5433235

How to send multipart response of jpegs

Having an embedded HTTP Server in an iOS application, How can I respond to an HTTP Request with a multipart message?
I'd like to asynchronously send JPEGs in a multipart response (MJPEG).
I've tried doing so using GCDWebServer, if it's not supported by it, any working alternative would be fine as long as it can also work on iOS.
GCDWebServer has no built-in API to create multipart messages. You would need to write such code and output a NSData object, which then you wrap into a GCDWebServerDataResponse that you return to the HTTP client.

iOS http authentication to windows using Transport WebHttpSecurityMode

I am trying get an iPad app to authenticate to Windows based application that uses WebHttpSecurityMode.Transport mode. I am assuming that I need specific fields in the http header to be filled out correctly to make this happen.
I am using NSURLConnections and then sending a request using sendSynchronousRequest. I am sending a rest request through the connection and receiving a (401) unauthorized. With a windows client I can use the same credentials and gain access.
I am setting the following fields in the http header
Accept, Accept-Charset, Accept-Encoding, Content-Type, Connection, Date, Basic, Authization.
Any suggestions would be greatly appreciated.

Resources