Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/Notes/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Read [**What’s new in 4D 21**](https://blog.4d.com/en-whats-new-in-4d-21/), th
- New "trim" commands to remove leading and trailing spaces from a string: [`Trim`](../commands/trim.md), [`Trim start`](../commands/trim-start.md), and [`Trim end`](../commands/trim-end.md).
- [`Num`](../commands/num.md) and [`String`](../commands/string.md) commands have been updated to support conversions in different bases (radix).

#### Behavior changes

- Web services (SOAP): when [scalable sessions](../WebServer/sessions.md#enabling-web-sessions) are enabled, web services now run in [**preemptive processes**](../Develop/preemptive.md) in compiled mode. Make sure your SOAP code is thread-safe.
- Web server: the support of deprecated `4DSYNC/` and `4DCGI/` URLs is removed. No specific processing is done on these URLs anymore.
- Web user sessions are now returned by [`Process activity`](../commands/process-activity.md).


## 4D 20 R10

Expand Down
2 changes: 1 addition & 1 deletion docs/WebServer/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The `On Web Authentication` database method is automatically called when a reque
The `On Web Authentication` database method is therefore called:

- when the web server receives a URL requesting a resource that does not exist
- when the web server receives a URL beginning with `4DACTION/`, `4DCGI/`...
- when the web server receives a URL beginning with `4DACTION/`
- when the web server receives a root access URL and no home page has been set in the Settings or by means of the [`WEB SET HOME PAGE`](../commands-legacy/web-set-home-page.md) command
- when the web server processes a tag executing code (e.g `4DSCRIPT`) in a semi-dynamic page.

Expand Down
12 changes: 6 additions & 6 deletions docs/WebServer/preemptiveWeb.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ The following table indicates whether the preemptive mode is used or is availabl
- REST Server: handles [ORDA data model class functions](../REST/ClassFunctions.md)
- Web Server: handles [web templates](templates.md), [4DACTION and database methods](httpRequests.md)
- Web Service Server: handles SOAP requests
- ***web setting*** means that the preemptive mode depends on a setting value:
- when [**Scalable sessions**](sessions.md#enabling-web-sessions) option is selected, the preemptive mode is automatically used for web processes.
- otherwise, the [**Use preemptive processes**](webServerConfig.md#use-preemptive-processes) option is taken into account.
- regarding Web service processes (server or client), preemptive mode is supported at method level. You just have to select "Can be run in preemptive processes" property for published SOAP server methods (see [Publishing a Web Service with 4D](https://doc.4d.com/4Dv20/4D/20.2/Publishing-a-Web-Service-with-4D.300-6750334.en.html)) or proxy client methods (see [Subscribing to a Web Service in 4D](https://doc.4d.com/4Dv20/4D/20.2/Subscribing-to-a-Web-Service-in-4D.300-6750336.en.html)) and make sure they are confirmed thread-safe by the compiler.
- ***web setting*** means that the preemptive mode depends on the [**scalable sessions**](sessions.md#enabling-web-sessions) status:
- if scalable sessions are enabled, the preemptive mode is automatically used for web and web service processes.
- if scalable sessions are not enabled:
- for web processes, the [**Use preemptive processes**](webServerConfig.md#use-preemptive-processes) option is taken into account.
- for web service processes (server or client), preemptive mode is supported at method level.



Expand All @@ -55,7 +56,7 @@ All 4D code executed by the web server must be thread-safe if you want your web

* [ORDA data model class functions](../REST/ClassFunctions.md) called via REST

For each of these methods and code parts, the compiler will check if the thread-safety rules are respected, and will return errors in case of issues. For more information about thread-safety rules, please refer to the *Writing a thread-safe method* paragraph in the *Processes* chapter of the [4D Language Reference](https://doc.4d.com) manual.
For each of these methods and code parts, the compiler will check if the [thread-safety rules are respected](../Develop/preemptive.md#writing-a-thread-safe-method), and will return errors in case of issues.

## Thread-safety of 4D web code

Expand All @@ -78,7 +79,6 @@ Of course, the code executed by these methods must also be thread-safe.
The following 4D Web Server URLs are thread-safe and can be used in preemptive mode:

* *4daction/* (the called project method must also be thread-safe)
* *4dcgi/* (the called database methods must also be thread-safe)
* *4dwebtest/*
* *4dblank/*
* *4dstats/*
Expand Down
2 changes: 1 addition & 1 deletion docs/WebServer/sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Web sessions allow to:

Web sessions are used for:

- [Web applications](gettingStarted.md) sending http requests,
- [Web applications](gettingStarted.md) sending http requests (including [SOAP Web services](../commands/theme/Web_Services_Server.md) and [/4DACTION](../WebServer/httpRequests.md#4daction) requests),
- calls to the [REST API](../REST/authUsers.md), which are used by [remote datastores](../ORDA/remoteDatastores.md) and [Qodly forms](qodly-studio.md).


Expand Down
3 changes: 0 additions & 3 deletions docs/WebServer/webServerConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,6 @@ This option enables the preemptive mode for your application's web server code w

The following settings are still supported but rely on deprecated features or technologies. It is usually recommended to keep default values.

#### Allow database access through 4DSYNC URLs

This option controls the support of HTTP synchronization requests containing deprecated */4DSYNC* URLs.

#### Session IP Address Validation

Expand Down
6 changes: 2 additions & 4 deletions docs/commands-legacy/on-web-authentication-database-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Let’s take the example of an Intranet connection. Suppose that the IP address
| http://123.45.67.89/Customers | /Customers |
| http://123.45.67.89/Customers/Add | /Customers/Add |
| 123.45.67.89/Do\_This/If\_OK/Do\_That | /Do\_This/If\_OK/Do\_That |

* **Header and Body of the HTTP request**
The second parameter (*$http*) is the header and the body of the HTTP request sent by the Web browser. Note that this information is passed to your **On Web Authentication database method** as it is. Its contents will vary depending on the nature of the Web browser which is attempting the connection.
If your application deals with this information, it is up to you to parse the header and the body.
Expand All @@ -71,7 +72,7 @@ If your application deals with this information, it is up to you to parse the he
The $ipBrowser parameter receives the IP address of the browser’s machine. This information can allow you to distinguish between Intranet and Internet connections.
**Note:** 4D returns IPv4 addresses in a hybrid IPv6/IPv4 format written with a 96-bit prefix, for example ::ffff:192.168.2.34 for the IPv4 address 192.168.2.34\. For more information, refer to the *Support of IPv6* section.
* **Server IP address**
The $ipServer parameter receives the IP address used to call the Web server. 4D since version 6.5 allows for multi-homing, which allows you to exploit machines with more than one IP address. For more information, please refer to the section *Web Server Settings*
The $ipServer parameter receives the IP address used to call the Web server. 4D allows for multi-homing, which allows you to exploit machines with more than one IP address. For more information, please refer to the section *Web Server Settings*
* **User Name and Password**
The $user and $pw parameters receive the user name and password entered by the user in the standard identification dialog box displayed by the browser. This dialog box appears for each connection, if a password management option has been selected in the Database Settings dialog box (see section *Connection Security*).

Expand Down Expand Up @@ -99,14 +100,11 @@ The On Web Authentication database method is automatically called, regardless of
The On Web Authentication database method is therefore called in the following cases:

* when 4D receives a URL beginning with *4DACTION/*
* when 4D receives a URL beginning with *4DCGI/*
* when 4D receives a URL beginning with *4DSYNC/*
* when 4D receives a URL requesting a static page that does not exist
* when 4D receives a root access URL and no home page has been set in the Database Settings or by means of the [WEB SET HOME PAGE](web-set-home-page.md) command
* when 4D processes a *4DSCRIPT* tag in a semi-dynamic page
* when 4D processes a *4DLOOP* tag based on a method in a semi-dynamic page.

**Compatibility note:** The database method is also called when 4D receives a URL beginning with *4DMETHOD/*. This URL is obsolete and is only kept for compatibility's sake.

Note that the On Web Authentication database method is NOT called when the server receives a URL requesting a valid static page.

Expand Down
27 changes: 6 additions & 21 deletions docs/commands-legacy/on-web-connection-database-method.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ displayed_sidebar: docs

##

<!--REF #_command_.On Web Connection database method.Summary-->The **On Web Connection database method** can be called in the following cases:

* the web server receives a request beginning with the *4DCGI* URL.<!-- END REF-->
* the web server receives an invalid request.
<!--REF #_command_.On Web Connection database method.Summary-->The **On Web Connection database method** can be called when the web server receives an invalid request.<!-- END REF-->


The request should have previously been accepted by the [On Web Authentication database method](on-web-authentication-database-method.md) (if it exists) and the web server must be launched.
Expand Down Expand Up @@ -69,19 +66,8 @@ Note that you are free to use this parameter at your convenience. 4D simply igno
* **Header and body of the HTTP request**
The second parameter (*$http*) is the header and the body of the HTTP request sent by the web browser. Note that this information is passed to your On Web Connection database method "as is". Its contents will vary depending on the nature of the web browser attempting the connection.

With Safari running on Mac OS, you may receive a header similar to this:

```
GET /favicon.ico HTTP/1.1Referer: http://123.45.67.89/4dcgi/testUser-Agent: Mozilla/5.0 (Macintosh; U; Intel macOS; fr-fr) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10Cache-Control: max-age=0Accept: */*Accept-Language: fr-frAccept-Encoding: gzip, deflateConnection: keep-aliveHost: 123.45.67.89
```

With Microsoft Internet Explorer 8 running on Windows, you may receive a header similar to this:

```
GET / HTTP/1.1Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*Accept-Language: fr-FRUser-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)Accept-Encoding: gzip, deflateHost: 123.45.67.89Connection: Keep-Alive
```

If your application uses this information, it is up to you to parse the header and the body.

If your application uses this information, it is up to you to parse the header and the body.

**Note:** For performance reasons, the size of this data cannot be more than 32 KB. Beyond this, they are truncated by the 4D HTTP server.
* **IP address of the web client**
Expand All @@ -97,12 +83,11 @@ The *$user* and *$pw* parameters receive the user name and password entered by t

## On Web Connection Database Method Calls

The **On Web Connection database method** can be used as the entry point for the 4D Web server, either using the special *4DCGI* URL, or using customized command URLs.
The **On Web Connection database method** can be used as the entry point for the 4D Web server using customized command URLs.

**Warning:** Calling a 4D command that displays an interface element ([DIALOG](../commands/dialog.md), [ALERT](alert.md), etc.) ends the method processing.

The **On Web Connection database method** is therefore called in the following cases:

* When 4D receives the */4DCGI* URL. The database method is called with the */4DCGI/<action>* URL in *$url*.
* When a Web page is called with a URL of type *<path>/<file>* is not found. The database method is called with the URL.
* When a Web page is called with a URL of type *<file>/* and no home page has been defined by default. The database method is called with the URL.
* When a Web page called with a URL of type `<path>/<file>` is not found. The database method is called with the URL.
* When a Web page is called with a URL of type `<file>/` and no home page has been defined by default. The database method is called with the URL.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The **On Web Legacy Close Session database method** is called by the 4D Web serv
* when the maximum period of inactivity for the session process is reached (480 minutes by default, modifiable using the [WEB SET OPTION](web-set-option.md) command),
* when the [WEB LEGACY CLOSE SESSION](web-legacy-close-session.md) command is called.

When this database method is called, the context of the session (variables and selections generated by the user) is still valid. This means that you can save data related to the session in order to be able to use them again subsequently, more specifically using the [QR SET DESTINATION](qr-set-destination.md).
When this database method is called, the context of the session (variables and selections generated by the user) is still valid. This means that you can save data related to the session in order to be able to use them again subsequently, more specifically using the [On Web Connection](./on-web-connection-database-method.md).

**Note:** In the context of a 4D Mobile session (which can generate several processes), the **On Web Legacy Close Session database method** is called for each Web process that is closed, allowing you to save all types of data (variables, selection, etc.) generated by the 4D Mobile session process.

Expand Down
2 changes: 1 addition & 1 deletion docs/commands-legacy/web-get-http-body.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ displayed_sidebar: docs

<!--REF #_command_.WEB GET HTTP BODY.Summary-->The **WEB GET HTTP BODY** command returns the body of the HTTP request being processed.<!-- END REF--> The HTTP body is returned as is, without processing or parsing.

This command can be called using a Web database method (*On Web Authentication Database Method*, [QR SET DESTINATION](qr-set-destination.md)) or any Web method.
This command can be called using a Web database method ([On Web Authentication](./on-web-authentication-database-method.md), [On Web Connection](./on-web-connection-database-method.md)) or any Web method.

In *body*, you can pass a variable or a field of the BLOB or Text type. The Text type is generally sufficient (the *body* parameter can receive up to 2 GB of text).

Expand Down
14 changes: 7 additions & 7 deletions docs/commands-legacy/web-get-http-header.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ displayed_sidebar: docs

<!--REF #_command_.WEB GET HTTP HEADER.Summary-->The **WEB GET HTTP HEADER** command returns either a string or two arrays, containing the HTTP header used for the currently processed request.<!-- END REF-->

This command can be called from within any method (*On Web Authentication Database Method* or [QR SET DESTINATION](qr-set-destination.md), method called by "*/4DACTION*"...) executed in a Web process.
This command can be called from within any method ([On Web Authentication](./on-web-authentication-database-method.md), [On Web Connection](./on-web-connection-database-method.md)), method called by "*/4DACTION*") executed in a Web process...

* **First syntax:** **WEB GET HTTP HEADER** **(header)**
When this syntax is used, the result returned in the *header* variable is as follows:
Expand Down Expand Up @@ -64,15 +64,15 @@ The following method allows getting any HTTP request header field content:
  // GetHTTPField (Text) -> Text
  // GetHTTPField (HTTP header name) -> HTTP header content

 var $0;$1 : Text
#DECLARE ($hName : Text) -> $hContent : Text
 var $vlItem : Integer
 ARRAY TEXT($names;0)
 ARRAY TEXT($values;0)
 $0:=""
 $hContent:=""
 WEB GET HTTP HEADER($names;$values)
 $vlItem:=Find in array($names;$1)
 $vlItem:=Find in array($names;$hName)
 If($vlItem>0)
    $0:=$values{$vlItem}
    $hContent:=$values{$vlItem}
 End if
```

Expand All @@ -83,7 +83,7 @@ The following method allows getting any HTTP request header field content:
 $cookie:=GetHTTPField("Cookie")
```

* You can send different pages according to the language set in the browser (for example in the [QR SET DESTINATION](qr-set-destination.md)):
* You can send different pages according to the language set in the browser (for example in the [On Web Connection](./on-web-connection-database-method.md) database method)):

```4d
 $language:=GetHTTPField("Accept-Language")
Expand All @@ -99,7 +99,7 @@ The following method allows getting any HTTP request header field content:

**Note:** Web browsers allow defining several languages by default. They are listed in the "Accept-Language" field, separated by a ";". Their priority is defined according to their position within the string; therefore it is a good idea to test language positions in the string.

* Here is an example of virtual hosts (for example, in the [QR SET DESTINATION](qr-set-destination.md)). The following names "home\_site.com", "home\_site1.com" and "home\_site2.com" are directed towards the same IP address, for example 192.1.2.3.
* Here is an example of virtual hosts. The following names "home\_site.com", "home\_site1.com" and "home\_site2.com" are directed towards the same IP address, for example 192.1.2.3.

```4d
 $host:=GetHTTPField("Host")
Expand Down
2 changes: 1 addition & 1 deletion docs/commands-legacy/web-get-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This command gets the value for all the variables which can be included in HTML

This command is valid regardless of the type of URL or form (POST or GET method) sent to the Web server.

This command can be called, if necessary, in the [QR SET DESTINATION](qr-set-destination.md) or any other 4D method resulting from a form submission.
This command can be called, if necessary, in the [On Web Connection](./on-web-connection-database-method.md) database method) or any other 4D method resulting from a form submission.

### About Web forms and their associated actions

Expand Down
26 changes: 5 additions & 21 deletions docs/commands-legacy/web-send-http-redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,14 @@ Note that the status of the request sent by this command is **302: Moved Tempora

## Example

You can use this command to execute custom requests in 4D by using static pages. Imagine that you have placed the following elements in a static HTML page:

![](../assets/en/commands/pict38648.en.png)

**Note:** The POST action “/4dcgi/rech” has been associated to the text area and to the **OK** and **Cancel** buttons.
```4d

var $targetURL : Text
$targetURL := "https://www.example.com"

In the [QR SET DESTINATION](qr-set-destination.md), you insert the following code:
WEB SEND HTTP REDIRECT($targetURL)

```4d
 Case of
    :($1="/4dcgi/rech") //When 4D receives this URL
  //If the OK button has been used and the ‘name’ field contains a Value
       If((bOK="OK") & (name#""))
  //Change the URL to execute the request code,
  //placed farther down in the same method
          WEB SEND HTTP REDIRECT("/4dcgi/rech?"+name)
       Else
  //Else return to the beginning page
          WEB SEND HTTP REDIRECT("/page1.htm")
       End if
       ...
    :($1="/4dcgi/rech?@") //If the URL has been redirected
       ... //Put the request code here
 End case
```


Expand Down
6 changes: 3 additions & 3 deletions docs/commands/process-activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ displayed_sidebar: docs
|Release|Changes|
|---|---|
|20 R7|Support of *sessionID* parameter|
|21|Support of web user sessions|

</details>

Expand Down Expand Up @@ -55,10 +56,9 @@ When executed on 4D in remote or local mode, `Process activity` always returns t

The "sessions" property contains a collection of objects describing all running sessions on the server. For a description of session object properties, please refer to the [`Session info`](session-info.md) command.

:::note Notes
:::note

- You can get the object of a session using the [Session](session.md) command.
- `Process activity` returns remote client sessions, stored procedure session and rest sessions but not Web sessions (limitation).
You can get the object of a session using the [Session](session.md) command.

:::

Expand Down
Loading
Loading