All Downloads are FREE. Search and download functionalities are using the official Maven repository.

libraries.Internet.pec Maven / Gradle / Ivy

define Email as native category with bindings:
	
	define category bindings as:
		Java: prompto.internet.Email
		C#: prompto.internet.Email
		Python2: Email from module: prompto.internet.Email
		Python3: Email from module: prompto.internet.Email
		JavaScript: Email from module: prompto/internet/Email.js

and methods:

	define setFrom as method receiving email and name = nothing doing:
		Java: this.setFrom(email, name);
		C#: this.setFrom(email, name);
		Python2: this.setFrom(email, name)
		Python3: this.setFrom(email, name);
		JavaScript: this.setFrom(email, name);


	define addTo as method receiving email and name = nothing doing:
		Java: this.addTo(email, name);
		C#: this.addTo(email, name);
		Python2: this.addTo(email, name)
		Python3: this.addTo(email, name);
		JavaScript: this.addTo(email, name);


	define addCC as method receiving email and name = nothing doing:
		Java: this.addCC(email, name);
		C#: this.addCC(email, name);
		Python2: this.addCC(email, name)
		Python3: this.addCC(email, name);
		JavaScript: this.addCC(email, name);


	define addBCC as method receiving email and name = nothing doing:
		Java: this.addBCC(email, name);
		C#: this.addBCC(email, name);
		Python2: this.addBCC(email, name)
		Python3: this.addBCC(email, name);
		JavaScript: this.addBCC(email, name);


	define setSubject as method receiving Text subject doing:
		Java: this.setSubject(subject);
		C#: this.setSubject(subject);
		Python2: this.setSubject(subject)
		Python3: this.setSubject(subject);
		JavaScript: this.setSubject(subject);


	define addBody as method receiving Text body and Text mimeType doing:
		Java: this.addBody(body, mimeType);
		C#: this.addBody(body, mimeType);
		Python2: this.addBody(body, mimeType)
		Python3: this.addBody(body, mimeType);
		JavaScript: this.addBody(body, mimeType);


	define send as method receiving Text hostName = Nothing, Integer port = -1, Boolean useTLS = false, login = Nothing, password = Nothing and Boolean useSSL = false doing:
		Java: this.send(hostName, port, useTLS, login, password, useSSL);
		C#: this.send(hostName, port, useTLS, login, password, useSSL);
		Python2: this.send(hostName, useTLS, port, login, password, useSSL)
		Python3: this.send(hostName, useTLS, port, login, password, useSSL);
		JavaScript: this.send(hostName, useTLS, port, login, password, useSSL);


define htmlEncode as native method receiving Text value returning Text doing:
	Java: return prompto.internet.Html.encode(value);
	C#: return System.Net.WebUtility.HtmlEncode(value);
	Python2: return escape(value) from module: cgi
	Python3: return escape(value) from module: html
	JavaScript: return htmlEncode(value); from module: prompto/internet/Html.js

define htmlDecode as native method receiving Text value returning Text doing:
	Java: return prompto.internet.Html.decode(value);
	C#: return System.Net.WebUtility.HtmlDecode(value);
	Python2: return HTMLParser().unescape(value) from module: HTMLParser
	Python3: return unescape(value) from module: html.parser
	JavaScript: return htmlDecode(value); from module: prompto/internet/Html.js


define "encode Html entity" as test method doing:
	encoded = htmlEncode ""
and verifying:
	encoded = "<ab>"


define "decode Html entity" as test method doing:
	encoded = htmlDecode "<ab>"
and verifying:
	encoded = ""


define "decode Html charcode" as test method doing:
	encoded = htmlDecode "a1b"
and verifying:
	encoded = "a1b"

define HttpMethod as enumerated Text with symbols:
	HTTP_CONNECT with "CONNECT" as value
	HTTP_DELETE with "DELETE" as value
	HTTP_GET with "GET" as value
	HTTP_HEAD with "HEAD" as value
	HTTP_OPTIONS with "OPTIONS" as value
	HTTP_PATCH with "PATCH" as value
	HTTP_POST with "POST" as value
	HTTP_PUT with "PUT" as value
	HTTP_TRACE with "TRACE" as value

define httpMethod as storable HttpMethod attribute

define HttpHeader as native category with attributes name and text, and bindings:

	define category bindings as:
		Java: prompto.internet.HttpHeader
		C#: prompto.internet.HttpHeader
		Python2: HttpHeader from module: prompto.internet.HttpHeader
		Python3: HttpHeader from module: prompto.internet.HttpHeader
		JavaScript: HttpHeader from module: prompto/internet/HttpHeader.js

define httpHeaders as HttpHeader[] attribute
	
define HttpContentType as enumerated Text with symbols:
	HTTP_URL_ENCODED with "application/x-www-form-urlencoded" as value
	HTTP_FORM_DATA with "multipart/form-data" as value
	HTTP_TEXT_PLAIN with "text/plain" as value
	HTTP_APPLICATION_JSON with "application/json" as value

define Url as native resource with attributes path, encoding, httpMethod and httpHeaders, and bindings:
	
	define category bindings as:
		Java: prompto.internet.Url
		C#: prompto.internet.Url
		Python2: Url from module: prompto.internet.Url
		Python3: Url from module: prompto.internet.Url
		JavaScript: Url from module: prompto/internet/Url.js

define url as Url attribute

define "reads from www.google.com" as test method doing:
	// need a cross-domain enabled page for browser testing
	content = read all from Url with "https://www.google.com/" as path
and verifying: 
	content contains "doctype"


define "reads async from www.google.com" as test method doing:
	// need a cross-domain enabled page for browser testing
	content = ""
	read all from Url with "https://www.google.com/" as path then with result:
		content = result
and verifying: 
	content contains "doctype"


define encodeURI as native method receiving Text uri returning Text doing:
    Java: return java.net.URLEncoder.encode(uri, "UTF-8");
    C#: return System.Web.HttpUtility.UrlEncode(uri);
    Python2: return quote(uri) from module: urllib
    Python3: return quote(uri) from module: urllib.parse
    JavaScript: return encodeURIComponent(uri);


define decodeURI as native method receiving Text uri returning Text doing:
    Java: return java.net.URLDecoder.decode(uri, "UTF-8");
    C#: return System.Web.HttpUtility.UrlDecode(uri);
    Python2: return unquote(uri) from module: urllib
    Python3: return unquote(uri) from module: urllib.parse
    JavaScript: return decodeURIComponent(uri);

define "encodes and decodes uri" as test method doing:
	uri = "Black Mamba"
	encoded = encodeURI uri
	decoded = decodeURI encoded
and verifying: 
	encoded = "Black%20Mamba" or encoded = "Black+Mamba"
	uri = decoded





© 2015 - 2025 Weber Informatics LLC | Privacy Policy