I am using Mongoose library to have a localhost server run in my system.
Now, through HTTP Connection OR Websocket Connection, I want to send files/documents/images/small audio files to the client who is making request to the local host.
Until now i was sending a simple json message via websockets and xml data via http connection to client (Browser) by using these Mongoose APIs
mg_send_data()
mg_websocket_write()
Since Mongoose is being used the whole implementation is in C
Kindly let me know if I can refer to any of the example code if there are any, OR any API documentation of Mongoose which would help me to achieve the above.
Looking forward for valuable responses.
From the github repository you will find :
the API documentation
severals samples that show how to implement websocket and sending MJPEG
Related
I am moving my app from Svelte SPA (original) to Sveltekit multi page app (new).
In the original app, I configure a http client up top and put it context using:
setContext(HTTP_CLIENT, httpClient)
Now the entire app can get that http client using
const httpClient = getContext(HTTP_CLIENT)
I do this because my app can be started with debug parameters than turn on http request logging.
I'm not clear how to do similar in Sveltekit, because it seems that pages do not share a context.
I tried sticking the http client in the session like this:
import { session } from "$app/stores";
$session.httpClient = httpClient
and I got:
Error: Failed to serialize session data: Cannot stringify arbitrary non-POJOs
So $session is meant to be serialized, ok. Does that mean that I need to put whatever debug parameters a user supplied in $session, and each page needs to freshly instantiate its own http client? Or is there some other idiomatic sveltekit way of doing this?
PS I know sveltekit has its own fetch so you might want to say "don't use your own http client", but my app uses many different service objects (graphql client for example) that can be configured in debug (and other) modes, so please don't zero in on the fact that my example is a http client.
One way around this could be to send down the configuration in the top __layout file, create the http client there and store in a store. Since stores are shared across all pages the client can then freely use this store.
We can send MMS using Twilio api in Salesforce.
As i know that using that code i can send MMS using Twilio in Salesforce.
Sending a MMS
properties.add(new TwilioNameValuePair('MediaUrl','https://www.twilio.com/packages/company/img/logos_downloadable_round.png'));
But it's seams that we have need to pass media file url.
But how can we take a input of file form Local machine and send them using Twilio MMS?
You can use twilio assets for sending local files.
- First you need to upload the local files on twilio assets.
- use the assets url and media url for sending Mms
Rajendra, hello! Megan from Twilio here.
This sounds similar to what I ran into building an OpenCV MMS implementation in this blog post.
The example there is in Python specifically, after writing an image to my local filesystem and making the desired modifications on it, I send it through:
#app.route('/uploads/<filename>', methods=['GET', 'POST'])
def uploaded_file(filename):
return send_from_directory(UPLOAD_FOLDER,
filename)
which handles the delivery of the following TwiML:
message.media('http://YourNgrokURL/uploads/{}'.format(filename))
You'll be needing the equivalent of Flask's send_from_directory to handle this in your implementation.
Hope this helps!
I am currently designing a web application using AngularJS. In this I am fetching and posting data via Rest API(s) with different methods. The data I retrieving is fetched in the form of JSON.
Problem:
Issue here is, while I am using https, the data sent and received via HTTP requests can still be seen in proxy tool or traffic monitors. All the JSON can be easily read from this.
Each of my request has a token attached in it's header which takes care of authentication. However, once authorized, there is some part I don't want to be displayed in/ caught in such monitoring tools.
Question:
This data is stored in an encrypted way in database and all, however while coming via HTTP request, it is first decrypted and then sent. How can I hide/protect this data?
You can't.
If you give it to the client, then the client has to be able to see it.
If the user has configured their browser to proxy requests, then the proxy is the client.
Once the data leaves your server in an HTTP response then anyone/anything thing the user of the client wants to trust with that data can access it. You don't have control at that point.
proxy tool or traffic monitors will see https data only if the client has accepted the man-in-the-middle (MITM) by installing the ssl certificate used by the MITM:
To see the content (other than the host name) of an https connection, someone who is neither the client or the server must do a MITM.
If someone do a MITM with a certificate not trusted by the client, the client will reject the connection.
WARNING: If the server do NOT use HSTS, the person doing the MITM can do an SSLSTRIP attack if the first connection is http. In that case, the MITM do not need a trusted certificate because the connection will stay in plain text (http)
I need to develop a web-based service on Google Appengine (Python 2.7) that involves the sending of sensitive data from a third-party website over to my site (preferably through SSL). Say that my url is https://example.appspot.com, and I want the third-party site http://example.com to send two values through a POST request, one is username and the other is password, to https://example.appspot.com/receiverhandler. This receiver handler is class ReceiverHandler(webapp2.RequestHandler). My question is basically: how can I send this POST data through an SSL connection? I'm not entirely familiar with the SSL protocol, so I have no idea where to begin.
Using urlfetch, just send it to the SSL-secured url: https://example.appspot.com/receiverhandler
This gives great explanation of how to do it, using POST params (payload):
https://developers.google.com/appengine/docs/python/urlfetch/
I want to save data using AngularJS and RestApi. I am sending an object in data parameter.
I tried both $http.post() direct method and $http() method , but non of these are working.
Always the error coming is "Method not allowed-405"
I am running on local machine.
Edit:
Eventually by doing some modifications like I specified "localhost:xxx" before the 'api/abc', now I am getting the error as "The requested resource does not support the http method 'POST'".
The reason is that the API you're using does not support POST requests to the URL you're trying to POST to
More info from http://www.checkupdown.com/status/E405.html below
All Web servers can be configured to allow or disallow any method. For example if a Web server is 'read-only' (no client can modify URL resources on the Web server), then it could be set up to disallow the PUT and DELETE methods. Similarly if there is no user input (all the Web pages are static), then the POST method could be disallowed. So 405 errors can arise because the Web server is not configured to take data from the client at all.