You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-23 22:05:15 +02:00
72 lines
2.2 KiB
Plaintext
Vendored
72 lines
2.2 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 4
|
|
description: Use URL encoding and other functions to work with HTTP-client in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
|
|
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, HTTP-client]
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
# Use URL encoding
|
|
Enables or disables standard encoding of special characters in URLs
|
|
|
|
|
|
|
|
`Function UseURLEncoding(Val Flag) Export`
|
|
|
|
| Parameter | CLI option | Type | Required | Description |
|
|
|-|-|-|-|-|
|
|
| Flag | - | Boolean | ✔ | Flag to use URL encoding |
|
|
|
|
|
|
Returns: DataProcessorObject.OPI_HTTPClient - This processor object
|
|
|
|
<br/>
|
|
|
|
:::tip
|
|
URL encoding is enabled by default
|
|
:::
|
|
|
|
:::caution
|
|
**NOCLI:** this method is not available in CLI version
|
|
:::
|
|
<br/>
|
|
|
|
|
|
```bsl title="1C:Enterprise/OneScript code example"
|
|
URL = "https://bin.openintegrations.dev";
|
|
URL = URL + "/get";
|
|
|
|
ParametersStructure = New Structure;
|
|
ParametersStructure.Insert("param1", "search?text");
|
|
ParametersStructure.Insert("param2", "John Doe");
|
|
ParametersStructure.Insert("param3", "value&another");
|
|
ParametersStructure.Insert("param4", "кириллица");
|
|
ParametersStructure.Insert("param5", "<script>alert('XSS')</script>");
|
|
|
|
NoEncoding = OPI_HTTPRequests.NewRequest()
|
|
.Initialize("https://example.com/page")
|
|
.SetURLParams(ParametersStructure)
|
|
.UseURLEncoding(False) // <---
|
|
.ProcessRequest("GET", False)
|
|
.ReturnRequest()
|
|
.ResourceAddress;
|
|
|
|
WithEncoding = OPI_HTTPRequests.NewRequest()
|
|
.Initialize("https://example.com/page")
|
|
.SetURLParams(ParametersStructure)
|
|
.ProcessRequest("GET", False)
|
|
.ReturnRequest()
|
|
.ResourceAddress;
|
|
```
|
|
|
|
|
|
|
|
|
|
```json title="Result"
|
|
{
|
|
"No encoding": "/page?param1=search?text¶m2=John Doe¶m3=value&another¶m4=кириллица¶m5=<script>alert('XSS')</script>",
|
|
"With encoding": "/page?param1=search%3Ftext¶m2=John%20Doe¶m3=value%26another¶m4=%D0%BA%D0%B8%D1%80%D0%B8%D0%BB%D0%BB%D0%B8%D1%86%D0%B0¶m5=%3Cscript%3Ealert%28%27XSS%27%29%3C%2Fscript%3E"
|
|
}
|
|
```
|