Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
WebRequest.Send
Send custom answer.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
WebHook | 11.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "WebRequest.Send"; WebRequest; Text { ; Encoding } ) More
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
WebRequest | The reference number of the web request. | $WebRequest | |
Text | The text to send out. Should use CRLF as line endings and end with two CRLF. |
||
Encoding | The text encoding for result. Default is UTF-8. Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the FAQ. |
"UTF8" | Optional |
Result
Returns number or error.
Description
Send custom answer.This allows you to assemble a custom HTTP response and send it.
The answer is sent above the connection to the other side where the request is coming from.
Please make sure your HTTP response header uses CRLF as line endings and ends with two CRLF. Then you may send additional content like e.g. JSON data.
Returns number of bytes sent on success.
Examples
Send HTTP response:
Set Variable [ $text ; Value: "HTTP/1.1 201 Tested¶Server: MyServer 1.0¶Connection: close¶Content-Length: 0¶¶" ]
Set Variable [ $text ; Value: MBS( "Text.ReplaceNewline"; $Text; 3 ) ]
Set Variable [ $r ; Value: MBS("WebRequest.Send"; $WebRequest; $text; "UTF-8") ]
Send RAW answer:
Set Variable [ $text ; Value: "Hello World!" & Char(13) & Char(10) ]
Set Variable [ $r ; Value: MBS("WebRequest.Send"; $WebRequest; $text; "UTF-8") ]
See also
Example Databases
Blog Entries
This function checks for a license.
Created 17th October 2021, last changed 5th November 2021