Movatterモバイル変換


[0]ホーム

URL:


CN115225707A - Resource access method and device - Google Patents

Resource access method and device
Download PDF

Info

Publication number
CN115225707A
CN115225707ACN202111664836.8ACN202111664836ACN115225707ACN 115225707 ACN115225707 ACN 115225707ACN 202111664836 ACN202111664836 ACN 202111664836ACN 115225707 ACN115225707 ACN 115225707A
Authority
CN
China
Prior art keywords
resource
proxy
request
domain
cross
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111664836.8A
Other languages
Chinese (zh)
Other versions
CN115225707B (en
Inventor
阮易强
朱奕嘉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co LtdfiledCriticalTencent Technology Shenzhen Co Ltd
Publication of CN115225707ApublicationCriticalpatent/CN115225707A/en
Application grantedgrantedCritical
Publication of CN115225707BpublicationCriticalpatent/CN115225707B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Landscapes

Abstract

Translated fromChinese

本申请公开了一种资源访问方法及装置,属于计算机技术领域。所述方法包括:获取目标应用发送的资源请求报文;若资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数;根据代理标识参数和位置信息生成跨域代理请求;将跨域代理请求发送至代理服务器;接收代理服务器发送的响应报文。本申请实施例提供的技术方案中,在目标应用发送的资源请求报文的基础上生成跨域代理请求,并在跨域代理请求中添加代理标识参数以标识跨域代理请求的唯一性,确保代理服务器在设置缓存策略的情况下成功接收跨域代理请求并返回正确的待访问资源,降低资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。

Figure 202111664836

The present application discloses a resource access method and device, which belong to the technical field of computers. The method includes: obtaining a resource request message sent by a target application; if the message sending mode of the resource request message is a cross-domain proxy mode, generating a proxy identification parameter; and generating a cross-domain proxy request according to the proxy identification parameter and location information; Send the cross-domain proxy request to the proxy server; receive the response message sent by the proxy server. In the technical solutions provided by the embodiments of the present application, a cross-domain proxy request is generated on the basis of a resource request message sent by a target application, and a proxy identification parameter is added to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, ensuring that the cross-domain proxy request is unique. The proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed under the condition of setting the caching policy, which reduces the complexity of resource access, improves the efficiency of resource access, and ensures the success rate and correct rate of resource access.

Figure 202111664836

Description

Translated fromChinese
资源访问方法及装置Resource access method and device

本申请要求于2021年04月16日递交的、申请号为202110411765.4、发明名称为“资源访问方法、装置、设备及存储介质”的中国申请的优先权,其全部内容通过引用并入本申请中。This application claims the priority of the Chinese application filed on April 16, 2021, with the application number of 202110411765.4 and the invention titled "Resource Access Method, Apparatus, Equipment and Storage Medium", the entire contents of which are incorporated into this application by reference .

技术领域technical field

本申请涉及计算机技术领域,特别涉及一种资源访问方法及装置。The present application relates to the field of computer technologies, and in particular, to a resource access method and device.

背景技术Background technique

低代码开发平台(Low-Code Development Platform,LCDP)是无需编码或通过少量代码就可以快速生成应用程序的开发平台。通过可视化进行应用程序开发的方法,使具有不同经验水平的开发人员可以通过图形化的用户界面,使用拖拽组件和模型驱动的逻辑来创建网页和移动应用程序。Low-Code Development Platform (LCDP) is a development platform that can quickly generate applications without coding or with a small amount of code. A visual approach to application development that enables developers of varying experience levels to create web and mobile applications using drag-and-drop components and model-driven logic through a graphical user interface.

若想要在低代码开发平台中快速预览业务应用程序(被开发的应用程序) 的效果,需要实时渲染当前应用程序,此时应用程序所属域名是低代码开发平台的域名。业务应用程序(被开发的应用程序)仅可以请求和低代码开发平台网站域名相同的接口,并不能请求其他业务域名接口。如果业务应用程序请求与其对应的业务域名接口,便出现跨域访问的情况,业务应用程序请求会被浏览器拦截。如果想要实现请求业务域名接口,需要接口提供方的业务服务器设置跨域资源共享(Cross-Origin Resource Sharing,CORS)配置,业务应用程序才能进行接口调试和效果预览。If you want to quickly preview the effect of the business application (the application being developed) in the low-code development platform, you need to render the current application in real time. At this time, the domain name to which the application belongs is the domain name of the low-code development platform. Business applications (developed applications) can only request the same interface as the low-code development platform website domain name, and cannot request other business domain name interfaces. If a business application requests its corresponding business domain name interface, cross-domain access occurs, and the business application request will be intercepted by the browser. If you want to implement the request business domain name interface, you need to set the Cross-Origin Resource Sharing (CORS) configuration on the business server of the interface provider, so that the business application can perform interface debugging and effect preview.

相关技术中,低代码开发平台中应用访问资源复杂度高、资源访问效率低。In the related art, the application access resources in the low-code development platform have high complexity and low resource access efficiency.

发明内容SUMMARY OF THE INVENTION

本申请实施例提供了一种资源访问方法及装置,降低了资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。The embodiments of the present application provide a resource access method and device, which reduce the resource access complexity, improve the resource access efficiency, and ensure the success rate and the correct rate of the resource access.

根据本申请实施例的一个方面,提供了一种资源访问方法,所述方法包括:According to an aspect of the embodiments of the present application, a resource access method is provided, the method comprising:

获取目标应用发送的资源请求报文,所述资源请求报文包括待访问资源的位置信息;obtaining a resource request message sent by the target application, where the resource request message includes location information of the resource to be accessed;

若所述资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数;根据所述代理标识参数和所述位置信息生成跨域代理请求;将所述跨域代理请求发送至所述代理服务器;其中,所述代理标识参数用于在所述代理服务器设置缓存策略的情况下,标识所述跨域代理请求的唯一性;If the message sending mode of the resource request message is a cross-domain proxy mode, generate a proxy identification parameter; generate a cross-domain proxy request according to the proxy identification parameter and the location information; send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a caching policy;

接收所述代理服务器发送的响应报文,所述响应报文包括所述待访问资源。A response message sent by the proxy server is received, where the response message includes the resource to be accessed.

根据本申请实施例的一个方面,提供了一种资源访问方法,所述方法包括:According to an aspect of the embodiments of the present application, a resource access method is provided, the method comprising:

接收跨域代理请求,所述跨域代理请求包括代理标识参数以及待访问资源的位置信息,所述代理标识参数用于在设置缓存策略的情况下,标识所述跨域代理请求的唯一性;receiving a cross-domain proxy request, where the cross-domain proxy request includes a proxy identification parameter and location information of the resource to be accessed, and the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set;

基于所述待访问资源的位置信息,生成资源获取请求;generating a resource acquisition request based on the location information of the resource to be accessed;

发送所述资源获取请求至资源服务器;sending the resource acquisition request to a resource server;

接收所述资源服务器发送的响应报文,所述响应报文包括所述待访问资源;receiving a response message sent by the resource server, where the response message includes the resource to be accessed;

转发所述响应报文至终端。Forward the response message to the terminal.

根据本申请实施例的一个方面,提供了一种资源访问装置,所述装置包括:According to an aspect of the embodiments of the present application, there is provided a resource access device, the device comprising:

请求获取模块,用于获取目标应用发送的资源请求报文,所述资源请求报文包括待访问资源的位置信息;a request acquisition module, configured to acquire a resource request message sent by the target application, where the resource request message includes location information of the resource to be accessed;

标识生成模块,用于若所述资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数;an identification generation module, configured to generate a proxy identification parameter if the message sending mode of the resource request message is a cross-domain proxy mode;

代理请求生成模块,用于根据所述代理标识参数和所述位置信息生成跨域代理请求;a proxy request generation module, configured to generate a cross-domain proxy request according to the proxy identification parameter and the location information;

请求发送模块,用于将所述跨域代理请求发送至所述代理服务器;其中,所述代理标识参数用于在所述代理服务器设置缓存策略的情况下,标识所述跨域代理请求的唯一性;A request sending module, configured to send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the unique cross-domain proxy request when the proxy server sets a caching policy sex;

报文接收模块,用于接收所述代理服务器发送的响应报文,所述响应报文包括所述待访问资源。A message receiving module, configured to receive a response message sent by the proxy server, where the response message includes the resource to be accessed.

根据本申请实施例的一个方面,提供了一种资源访问装置,所述装置包括:According to an aspect of the embodiments of the present application, there is provided a resource access device, the device comprising:

请求接收模块,用于接收跨域代理请求,所述跨域代理请求包括代理标识参数以及待访问资源的位置信息,所述代理标识参数用于在设置缓存策略的情况下,标识所述跨域代理请求的唯一性;A request receiving module, configured to receive a cross-domain proxy request, where the cross-domain proxy request includes a proxy identification parameter and location information of the resource to be accessed, and the proxy identification parameter is used to identify the cross-domain proxy when a cache policy is set Uniqueness of proxy requests;

资源请求生成模块,用于基于所述待访问资源的位置信息,生成资源获取请求;a resource request generation module, configured to generate a resource acquisition request based on the location information of the resource to be accessed;

资源请求发送模块,用于发送所述资源获取请求至资源服务器;a resource request sending module, configured to send the resource acquisition request to a resource server;

资源接收模块,用于接收所述资源服务器发送的响应报文,所述响应报文包括所述待访问资源;a resource receiving module, configured to receive a response message sent by the resource server, where the response message includes the resource to be accessed;

报文转发模块,用于转发所述响应报文至终端。A message forwarding module, configured to forward the response message to the terminal.

根据本申请实施例的一个方面,提供了一种计算机设备,所述计算机设备包括处理器和存储器,所述存储器中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由所述处理器加载并执行以实现上述资源访问方法。According to an aspect of the embodiments of the present application, a computer device is provided, the computer device includes a processor and a memory, and the memory stores at least one instruction, at least one program, a code set or an instruction set, the at least one The instructions, the at least one piece of program, the code set or the instruction set are loaded and executed by the processor to implement the above resource access method.

根据本申请实施例的一个方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或指令集由处理器加载并执行以实现上述资源访问方法。According to an aspect of the embodiments of the present application, a computer-readable storage medium is provided, where at least one instruction, at least one segment of program, code set or instruction set is stored in the storage medium, the at least one instruction, the at least one segment of The program, the code set or the instruction set is loaded and executed by the processor to implement the above-mentioned resource access method.

根据本申请实施例的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述资源访问方法。According to one aspect of the embodiments of the present application, there is provided a computer program product or computer program, where the computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned resource access method.

本申请实施例提供的技术方案可以带来如下有益效果:The technical solutions provided in the embodiments of the present application can bring the following beneficial effects:

利用服务器直接请求没有同源策略的特点,在目标应用发送的资源请求报文的基础上生成跨域代理请求,并在跨域代理请求中添加代理标识参数以标识跨域代理请求的唯一性,确保代理服务器在设置缓存策略的情况下成功接收跨域代理请求并返回正确的待访问资源,无需跨域资源共享配置,即可实现资源访问,降低资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。Taking advantage of the fact that the server's direct request does not have the same-origin policy, the cross-domain proxy request is generated based on the resource request message sent by the target application, and the proxy identification parameter is added to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request. Ensure that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed under the condition of setting the caching policy. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of resource access, improving the efficiency of resource access, and ensuring The success rate and correct rate of resource access.

附图说明Description of drawings

为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained from these drawings without creative effort.

图1是本申请一个实施例提供的应用程序运行环境的示意图;1 is a schematic diagram of an application running environment provided by an embodiment of the present application;

图2示例性示出了应用同源策略的示意图;Fig. 2 exemplarily shows the schematic diagram of applying the same-origin policy;

图3示例性示出了跨域资源共享的网络示意图;Fig. 3 exemplarily shows a network diagram of cross-domain resource sharing;

图4是本申请一个实施例提供的资源访问方法的流程图;4 is a flowchart of a resource access method provided by an embodiment of the present application;

图5示例性示出了一种设置跨域代理模式的页面示意图;FIG. 5 exemplarily shows a schematic diagram of a page for setting a cross-domain proxy mode;

图6是本申请另一个实施例提供的资源访问方法的流程图;6 is a flowchart of a resource access method provided by another embodiment of the present application;

图7是本申请另一个实施例提供的资源访问方法的流程图;7 is a flowchart of a resource access method provided by another embodiment of the present application;

图8示例性示出了跨域代理模式下资源访问流程的示意图;FIG. 8 exemplarily shows a schematic diagram of a resource access process in a cross-domain proxy mode;

图9是本申请一个实施例提供的资源访问装置的框图;9 is a block diagram of a resource access device provided by an embodiment of the present application;

图10是本申请另一个实施例提供的资源访问装置的框图;10 is a block diagram of a resource access device provided by another embodiment of the present application;

图11是本申请一个实施例提供的计算机设备的结构框图;11 is a structural block diagram of a computer device provided by an embodiment of the present application;

图12是本申请一个实施例提供的计算机设备的结构框图。FIG. 12 is a structural block diagram of a computer device provided by an embodiment of the present application.

具体实施方式Detailed ways

本申请实施例涉及云技术领域和区块链技术领域,下面对此进行简单说明:The embodiments of the present application relate to the field of cloud technology and the field of blockchain technology, which are briefly described below:

云技术(Cloud technology):基于云计算商业模式应用的网络技术、信息技术、整合技术、管理平台技术、应用技术等的总称,可以组成资源池,按需所用,灵活便利。云计算技术将变成重要支撑。技术网络系统的后台服务需要大量的计算、存储资源,如视频网站、图片类网站和更多的门户网站。伴随着互联网行业的高度发展和应用,将来每个物品都有可能存在自己的识别标志,都需要传输到后台系统进行逻辑处理,不同程度级别的数据将会分开处理,各类行业数据皆需要强大的系统后盾支撑,只能通过云计算来实现。Cloud technology: The general term for network technology, information technology, integration technology, management platform technology, and application technology based on cloud computing business models. Cloud computing technology will become an important support. Background services of technical network systems require a lot of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the back-end system for logical processing. Data of different levels will be processed separately, and all kinds of industry data need to be strong. The system backing support can only be achieved through cloud computing.

云计算(Cloud computing):指IT基础设施的交付和使用模式,指通过网络以按需、易扩展的方式获得所需资源;广义云计算指服务的交付和使用模式,指通过网络以按需、易扩展的方式获得所需服务。这种服务可以是IT和软件、互联网相关,也可是其他服务。云计算是网格计算(Grid Computing)、分布式计算(Distributed Computing)、并行计算(Parallel Computing)、效用计算(Utility Computing)、网络存储(NetworkStorageTechnologies)、虚拟化(Virtualization)、负载均衡(Load Balance)等传统计算机和网络技术发展融合的产物。Cloud computing: refers to the delivery and use mode of IT infrastructure, which refers to obtaining the required resources through the network in an on-demand and easy-to-expand manner; cloud computing in a broad sense refers to the delivery and use mode of services, which refers to the on-demand and easy-to-expand through network. , easily scalable way to obtain the required services. Such services can be IT and software, Internet-related, or other services. Cloud computing is Grid Computing, Distributed Computing, Parallel Computing, Utility Computing, Network Storage Technologies, Virtualization, Load Balance ) and other products of the integration of traditional computer and network technology development.

区块链(Blockchain)是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层。狭义来讲,区块链是一种按照时间顺序将数据区块以顺序相连的方式组合成的一种链式数据结构,并以密码学方式保证的不可篡改和不可伪造的分布式账本,即区块链中的数据一旦记录下来将不可逆。Blockchain is a new application mode of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. The blockchain is essentially a decentralized database, which is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify the validity of its information. (anti-counterfeiting) and generate the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer. In a narrow sense, blockchain is a chain data structure that combines data blocks in a sequential manner according to time sequence, and is cryptographically guaranteed to be an untamperable and unforgeable distributed ledger, that is, Once the data in the blockchain is recorded, it is irreversible.

为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

请参考图1,其示出了本申请一个实施例提供的应用程序运行环境的示意图。该应用程序运行环境可以包括:终端10和服务器20。Please refer to FIG. 1 , which shows a schematic diagram of an application running environment provided by an embodiment of the present application. The application running environment may include: a terminal 10 and aserver 20 .

终端10可以是诸如手机、平板电脑、游戏主机、电子书阅读器、多媒体播放设备、可穿戴设备、PC(Personal Computer,个人计算机)等电子设备。终端 10中可以安装应用程序的客户端。The terminal 10 may be an electronic device such as a mobile phone, a tablet computer, a game console, an e-book reader, a multimedia playback device, a wearable device, a PC (Personal Computer, personal computer) and the like. A client in the terminal 10 that can install applications.

在本申请实施例中,上述应用程序可以是任何能够发送网络请求的应用程序,网络请求既可以直接发送至待访问资源所在的资源服务器,也可以通过代理服务器请求资源服务器中的待访问资源。典型地,该应用程序为应用开发程序,例如低代码开发平台。由用户在低代码开发平台开发快速生成的目标应用,可在低代码开发平台中调试预览,通过低代码开发平台进行网络连接和数据传输,目标应用发送的网络请求既可以直接发送至为目标应用提供后台服务的资源服务器,也可以将低代码开发平台的后台服务器作为云端代理服务器,以帮助目标应用获取资源服务器中的待访问资源。当然,除了应用开发程序之外,其它类型的应用程序中也能够发送网络请求。例如,浏览器类应用程序、社交类应用程序、互动娱乐类应用程序、虚拟现实(Virtual Reality,VR)类应用程序、增强现实(AugmentedReality,AR)类应用程序、三维地图程序等,本申请实施例对此不作限定。另外,对于不同的应用程序来说,其发送的网络请求以及请求的网络资源也会有所不同,这都可以根据实际需求预先进行配置,本申请实施例对此不作限定。可选地,终端10中运行有上述应用程序的客户端。In this embodiment of the present application, the above application program may be any application program capable of sending network requests. The network request may be directly sent to the resource server where the resource to be accessed is located, or may request the resource to be accessed in the resource server through a proxy server. Typically, the application is an application development program, such as a low-code development platform. The user develops the quickly generated target application on the low-code development platform, can debug and preview in the low-code development platform, and perform network connection and data transmission through the low-code development platform. The network request sent by the target application can be directly sent to the target application. The resource server that provides background services can also use the background server of the low-code development platform as a cloud proxy server to help the target application obtain the resources to be accessed in the resource server. Of course, in addition to application development programs, other types of applications can also send network requests. For example, browser applications, social applications, interactive entertainment applications, virtual reality (Virtual Reality, VR) applications, augmented reality (Augmented Reality, AR) applications, 3D map programs, etc., are implemented in this application. The example does not limit this. In addition, for different application programs, the network request sent by the application program and the requested network resources will also be different, which can be pre-configured according to actual requirements, which is not limited in this embodiment of the present application. Optionally, the client terminal of the above application program runs in the terminal 10 .

服务器20用于为终端10中的应用程序的客户端提供后台服务或者云端代理服务。例如,服务器20可以是上述应用程序的后台服务器、也可以是单独的云端代理服务器。服务器20可以是一台服务器,也可以是由多台服务器组成的服务器集群,或者是一个云计算服务中心。可选地,服务器20同时为多个终端 10中的应用程序提供后台服务。Theserver 20 is used to provide a background service or a cloud proxy service for the client of the application program in the terminal 10 . For example, theserver 20 may be the background server of the above application, or may be a separate cloud proxy server. Theserver 20 may be a server, a server cluster composed of multiple servers, or a cloud computing service center. Optionally, theserver 20 provides background services for applications inmultiple terminals 10 at the same time.

可选地,终端10和服务器20之间可通过网络30进行互相通信。Optionally, the terminal 10 and theserver 20 can communicate with each other through thenetwork 30 .

在介绍本申请提供的方法实施例之前,先对本申请方法实施例中可能涉及的相关术语或者名词进行简要介绍,以便于本申请领域技术人员理解。Before introducing the method embodiments provided in the present application, relevant terms or nouns that may be involved in the method embodiments of the present application are briefly introduced to facilitate the understanding of those skilled in the art of the present application.

计算机与网络设备要相互通信,双方就必须基于相同35的方法。比如,如何探测到通信目标、由哪一边先发起通信、使用哪种语言进行通信、怎样结束通信等规则都需要事先确定。不同的硬件、操作系统之间的通信,所有的这一切都需要一种规则。而我们就把这种规则称为协议(protocol)。TCP/IP是互联网相关的各类协议族的总称。For computers and network devices to communicate with each other, both sides must be based on the same 35 method. For example, rules such as how to detect the communication target, which side initiates the communication first, which language is used for communication, and how to end the communication need to be determined in advance. Communication between different hardware, operating systems, all of this requires a discipline. And we call this rule a protocol. TCP/IP is a general term for various protocol families related to the Internet.

超文本传输协议(Hypertext Transfer Protocol,HTTP)是请求-响应协议,它通常运行在TCP之上。它指定了客户端可能发送给服务器什么样的消息以及得到什么样的响应。Hypertext Transfer Protocol (HTTP) is a request-response protocol, which usually runs on top of TCP. It specifies what kind of messages the client might send to the server and what kind of response it gets.

云端:是指线上服务器。Cloud: refers to the online server.

代理服务器:是客户端与服务器之间的一个中转站,当用户访问网络上资源的时候,可通过代理服务器来访问目标资源,再返回对应的结果。其基本行为就是接收客户端发送的请求后转发给其他服务器。在HTTP通信过程中,可级联多台代理服务器。请求和响应的转发会经过数台类似锁链一样连接起来的代理服务器。转发时,需要附加首部字段以标记出经过的主机信息。Proxy server: It is a transfer station between the client and the server. When users access resources on the network, they can access the target resources through the proxy server, and then return the corresponding results. Its basic behavior is to receive the request sent by the client and forward it to other servers. During HTTP communication, multiple proxy servers can be cascaded. Requests and responses are forwarded through several proxy servers connected like a chain. When forwarding, additional header fields are required to mark the passing host information.

持有资源实体的服务器被称为源服务器。从源服务器返回的响应经过代理服务器后再传给客户端。The server holding the resource entity is called the origin server. The response returned from the origin server passes through the proxy server and then forwards it to the client.

同源策略:是指在Web浏览器中,允许某个网页脚本访问另一个网页的数据,但前提是这两个网页必须有相同的URI、主机名和端口号,一旦两个网站满足上述条件,这两个网站就被认定为具有相同来源。此策略可防止某个网页上的恶意脚本通过该页面的文档对象模型访问另一网页上的数据。在一个示例中,如图2所示,其示例性示出了应用同源策略的示意图。终端20中浏览器加载的网页的域名为www.site-a.com,若用户通过该网页请求向域名同样为 www.site-a.com的服务器21请求资源,浏览器可通过终端20,向域名为www.site-a.com的服务器21发送网络请求,以请求响应的资源。服务器21收到该请求后,判断该网络请求的发送方的域名与本地域名是否一致,若都是 www.site-a.com,且协议版本与端口均一致,便会向终端20发送携带有网络请求对应的网络资源的响应报文。若用户通过该网页向域名为www.site-b.com的服务器22请求资源,因同源策略的限制,即该网页的域名www.site-a.com与服务器22的域名www.site-b.com不一致,会导致此次网络请求失败。Same-origin policy: In a web browser, a web page script is allowed to access the data of another web page, but the premise is that the two web pages must have the same URI, host name and port number. Once the two websites meet the above conditions, The two sites are identified as having the same origin. This policy prevents malicious scripts on one web page from accessing data on another web page through that page's Document Object Model. In one example, as shown in FIG. 2 , it exemplarily shows a schematic diagram of applying the same-origin policy. The domain name of the webpage loaded by the browser in the terminal 20 is www.site-a.com. If the user requests resources from theserver 21 whose domain name is also www.site-a.com through the webpage request, the browser can use the terminal 20 to request the resource. Theserver 21 whose domain name is www.site-a.com sends a network request to request a corresponding resource. After receiving the request, theserver 21 determines whether the domain name of the sender of the network request is consistent with the local domain name. The response message of the network resource corresponding to the network request. If the user requests resources from theserver 22 whose domain name is www.site-b.com through the webpage, due to the restriction of the same-origin policy, that is, the domain name of the webpage www.site-a.com and the domain name of theserver 22 www.site-b The .com is inconsistent, which will cause the network request to fail.

跨域资源共享(Cross-Origin Resource Sharing,CORS)是用于让网页的受限资源能够被其他域名的页面访问的一种机制。通过该机制,页面能够自由地使用不同源(cross-origin)的图片、样式、脚本、iframes以及视频。一些跨域的请求常常会被同源策略(Same-origin policy)所禁止的。跨域资源共享定义了一种方式,使浏览器和服务器之间能互相确认是否足够安全以至于能使用跨域请求(cross-origin requests)。在一个示例中,如图3所示,其示例性示出了跨域资源共享的网络示意图。终端30中显示有域名为domain-a.com的浏览器页面 31,浏览器页面31中的图像32是由域名为domain-a.com的服务器33提供的,浏览器页面31向服务器33发送图像32的获取请求,服务器33收到该请求后,向终端30发送图像32。而浏览器页面31中的图像34是由域名为domain-b.com 的服务器35提供的,由于服务器35与浏览器页面31的域名不同,两者之间存在同源策略限制,因此服务器35中需要设置跨域资源共享的配置信息,只有在服务器35中设置允许浏览器页面31进行跨域资源共享的配置信息后,服务器 35与浏览器页面31才能突破两者之间的同源策略限制,由终端30向服务器35 发送图像34的获取请求,服务器35接收到图像34的获取请求后向终端30发送图像34。这样,浏览器页面31中才可以正常显示图像34。Cross-Origin Resource Sharing (CORS) is a mechanism for enabling restricted resources of web pages to be accessed by pages of other domains. Through this mechanism, pages are free to use cross-origin images, styles, scripts, iframes, and videos. Some cross-origin requests are often prohibited by the same-origin policy. Cross-origin resource sharing defines a way for browsers and servers to mutually confirm that they are secure enough to use cross-origin requests. In one example, as shown in FIG. 3 , it exemplarily shows a network diagram of cross-domain resource sharing. The terminal 30 displays abrowser page 31 whose domain name is domain-a.com, theimage 32 in thebrowser page 31 is provided by aserver 33 whose domain name is domain-a.com, and thebrowser page 31 sends the image to theserver 33 32 . After receiving the request, theserver 33 sends theimage 32 to the terminal 30 . Theimage 34 in thebrowser page 31 is provided by theserver 35 whose domain name is domain-b.com. Since the domain names of theserver 35 and thebrowser page 31 are different, there is a same-origin policy restriction between the two, so theserver 35 has a different domain name. The configuration information of cross-domain resource sharing needs to be set. Only after the configuration information that allows thebrowser page 31 to perform cross-domain resource sharing is set in theserver 35, theserver 35 and thebrowser page 31 can break through the same-origin policy restriction between the two. The terminal 30 sends an acquisition request for theimage 34 to theserver 35 , and theserver 35 sends theimage 34 to the terminal 30 after receiving the acquisition request for theimage 34 . In this way, theimage 34 can be displayed normally in thebrowser page 31 .

URI(Uniform Resource Identifier,统一资源标识符),规定统一的格式可方便处理多种不同类型的资源,而不用根据上下文环境来识别资源指定的访问方式。另外,加入新增的协议方案(如http:或ftp:)也更容易。Resource资源的定义是“可标识的任何东西”。不仅是文档文件,图像或服务(例如当天的天气预报)等能够区别于其他类型的,全都可作为资源。另外,资源不仅可以是单一的,也可以是多数的集合体。Identifier表示可标识的对象。也称为标识符。综上所述,URI就是由某个协议方案表示的资源的定位标识符。协议方案是指访问资源所使用的协议类型名称。URI (Uniform Resource Identifier, Uniform Resource Identifier), specifies a unified format to facilitate the processing of multiple different types of resources, without identifying the access method specified by the resource according to the context. In addition, it is easier to add new protocol schemes such as http: or ftp:. The definition of Resource is "anything that can be identified". Not only document files, but also images or services (such as the weather forecast for the day) can be distinguished from other types, all of which can be used as resources. In addition, the resource may be not only a single, but also a plurality of aggregates. Identifier represents an identifiable object. Also called an identifier. In summary, a URI is a location identifier for a resource represented by a protocol scheme. The protocol scheme refers to the name of the protocol type used to access the resource.

URL(UniformResource Locator,统一资源定位符),URI用字符串标识某一互联网资源,而URL表示资源的地点(互联网上所处的位置)。可见URL是 URI的子集。URL (UniformResource Locator, Uniform Resource Locator), URI identifies a certain Internet resource with a string, and URL indicates the location of the resource (the location on the Internet). Visible URLs are a subset of URIs.

XMLHTTP是一组API函数集,可被JavaScript、JScript、VBScript以及其它web浏览器内嵌的脚本语言调用,通过HTTP在浏览器和web服务器之间收发XML或其它数据。XMLHTTP最大的好处在于可以动态地更新网页,它无需重新从服务器读取整个网页,也不需要安装额外的插件。该技术被许多网站使用,以实现快速响应的动态网页应用。例如:Google的Gmail服务、Google Suggest 动态查找界面以及Google Map地理信息服务。XMLHTTP is a set of API functions that can be invoked by JavaScript, JScript, VBScript and other scripting languages embedded in web browsers to send and receive XML or other data between browsers and web servers through HTTP. The biggest advantage of XMLHTTP is that it can dynamically update web pages without re-reading the entire web page from the server or installing additional plug-ins. This technology is used by many websites to achieve fast and responsive dynamic web applications. For example: Google's Gmail service, Google Suggest dynamic search interface and Google Map geographic information service.

Ajax(Asynchronous JavaScript and XML,异步JavaScript与XML技术)是一种有效利用JavaScript和DOM(Document Object Model,文档对象模型)的操作,以达到局部Web页面替换加载的异步通信手段。和以前的同步通信相比,由于它只更新一部分页面,响应中传输的数据量会因此而减少,这一优点显而易见。Ajax的核心技术是名为XMLHttpRequest的API,通过JavaScript脚本语言的调用就能和服务器进行HTTP通信。借由这种手段,就能从已加载完毕的 Web页面上发起请求,只更新局部页面。Ajax (Asynchronous JavaScript and XML, asynchronous JavaScript and XML technology) is an asynchronous communication method that effectively utilizes JavaScript and DOM (Document Object Model, Document Object Model) to achieve partial Web page replacement loading. Compared to the previous synchronous communication, since it only updates a part of the page, the amount of data transferred in the response is reduced, which is an obvious advantage. The core technology of Ajax is an API called XMLHttpRequest, which can communicate with the server through HTTP calls by the JavaScript scripting language. In this way, a request can be initiated from a loaded Web page and only a partial page is updated.

请参考图4,其示出了本申请一个实施例提供的资源访问方法的流程图。该方法可应用于计算机设备中,所述计算机设备是指具备数据计算和处理能力的电子设备,如各步骤的执行主体可以是图1所示的应用程序运行环境中的终端 10。该方法可以包括以下几个步骤(410~450)。Please refer to FIG. 4 , which shows a flowchart of a resource access method provided by an embodiment of the present application. The method can be applied to computer equipment, which refers to electronic equipment with data computing and processing capabilities, for example, the execution subject of each step may be the terminal 10 in the application running environment shown in FIG. 1 . The method may include the following steps (410-450).

步骤410,获取目标应用发送的资源请求报文。Step 410: Obtain the resource request message sent by the target application.

可选地,目标应用为程序开发应用中调试预览的应用。资源请求报文包括待访问资源的位置信息。Optionally, the target application is a debug preview application in the program development application. The resource request message includes location information of the resource to be accessed.

资源请求报文是指为了请求访问服务器上的网络资源发送的请求报文。The resource request message refers to a request message sent to request access to network resources on the server.

可选地,获取目标应用在调试预览过程中发送的资源请求报文。上述待访问资源是指目标应用在调试预览过程中请求的网络资源。Optionally, obtain a resource request message sent by the target application during the debugging preview process. The above resource to be accessed refers to the network resource requested by the target application in the process of debugging and previewing.

在一种可能的实施方式中,终端中加载显示程序开发应用的应用页面,在程序开发应用的应用页面中显示目标应用页面的调试预览页面。用户可以在目标应用的调试预览页面中执行调试操作。在用户操作涉及资源访问的情况下,会触发生成相应的资源访问指令,响应于资源访问指令,目标应用生成资源请求报文。目标应用为获取待访问资源,需要向服务器发送资源请求报文,上述服务器可以是为目标应用提供网络资源服务的后台服务器,也可以是云端代理服务器。可选地,程序开发应用的后台服务器可以作为目标应用的代理服务器。In a possible implementation manner, an application page displaying the program development application is loaded in the terminal, and a debugging preview page of the target application page is displayed in the application page of the program development application. Users can perform debug operations in the debug preview page of the target app. When the user operation involves resource access, it will trigger the generation of a corresponding resource access instruction, and in response to the resource access instruction, the target application generates a resource request message. In order to obtain the resource to be accessed, the target application needs to send a resource request message to the server. The server may be a background server that provides network resource services for the target application, or a cloud proxy server. Optionally, the background server of the program development application can serve as the proxy server of the target application.

在一种可能的实施方式中,目标应用可通过调用程序开发应用的请求发送接口,发送资源请求报文。可选地,上述请求发送接口是应用开发程序为目标应用发送网络请求设置的应用程序接口。程序开发应用基于请求发送规则,拦截目标应用发送的资源请求报文。由于目标应用是运行在程序开发应用下的,其所用到的所有API都是由程序开发应用提供的,因此作为程序开发应用侧可以拦截目标的所有HTTP请求。比如程序开发应用提供的HTTP请求API是 app.request,即可在app.requeset函数方法里面编写代码逻辑对所有的请求进行拦截。In a possible implementation manner, the target application may send the resource request message by invoking the request sending interface of the program development application. Optionally, the above-mentioned request sending interface is an application program interface set by the application development program for sending a network request to the target application. The program development application intercepts the resource request message sent by the target application based on the request sending rule. Since the target application runs under the program development application, all APIs used by the target application are provided by the program development application, so the program development application side can intercept all HTTP requests of the target. For example, the HTTP request API provided by the program development application is app.request, and you can write code logic in the app.requeset function method to intercept all requests.

步骤420,若资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数。Step 420: If the message sending mode of the resource request message is the cross-domain proxy mode, generate a proxy identification parameter.

报文发送模式是指请求报文向服务器发送的方式。可选地,报文发送模式包括同域发送模式、跨域代理模式。上述同域发送模式是指报文发送方与报文接收方符合同源策略的发送方式,报文发送方与报文接收方的域名,协议,端口均相同。上述跨域代理模式是指报文发送方与报文接收方的域名、协议、端口任一项不同的情况下,报文发送方与报文接收方通过代理服务传输报文的方式。The message sending mode refers to the way in which request messages are sent to the server. Optionally, the message sending mode includes a same-domain sending mode and a cross-domain proxy mode. The above-mentioned same-domain sending mode refers to the sending method in which the message sender and the message receiver conform to the same-origin policy. The domain name, protocol, and port of the message sender and the message receiver are the same. The above-mentioned cross-domain proxy mode refers to the way in which the message sender and the message receiver transmit messages through a proxy service when any of the domain names, protocols, and ports of the message sender and the message receiver are different.

其中,代理标识参数用于在代理服务器设置缓存策略的情况下,标识跨域代理请求的唯一性。The proxy identifier parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets the cache policy.

缓存是指代理服务器或客户端本地磁盘内保存的资源副本。利用缓存可减少对源服务器的访问,因此也就节省了通信流量和通信时间。上述缓存策略是指预先将资源的副本(缓存)保存在代理服务器或者客户端上。当代理服务器或者客户端再次接收到对相同资源的请求时,就可以不从源服务器那里获取资源,而是将之前缓存的资源作为响应返回,减少网络带宽的流量。A cache is a copy of a resource held on a proxy server or client's local disk. Using caching reduces access to origin servers, thus saving communication traffic and communication time. The above caching strategy refers to storing a copy (cache) of the resource on the proxy server or the client in advance. When the proxy server or client receives a request for the same resource again, it can not obtain the resource from the origin server, but return the previously cached resource as a response, reducing the traffic of network bandwidth.

可选地,缓存具有有效期限。即便代理服务器或者客户端内有缓存,也不能保证每次都会返回对同资源的请求。因为这关系到被缓存资源的有效性问题,当遇上源服务器上的资源更新时,如果还是使用不变的缓存,那就会演变成返回更新前的“旧”资源了。即使存在缓存,也会因为客户端的要求、缓存的有效期等因素,向源服务器确认资源的有效性。若判断缓存失效,将会再次从源服务器上获取更新后的网络资源。Optionally, the cache has an expiration date. Even if there is a cache in the proxy server or client, there is no guarantee that a request for the same resource will be returned every time. Because this is related to the validity of the cached resource, when the resource on the origin server is updated, if the unchanged cache is still used, it will evolve into returning the "old" resource before the update. Even if there is a cache, the validity of the resource will be confirmed to the origin server due to the client's request and the validity period of the cache. If it is determined that the cache is invalid, the updated network resources will be obtained from the origin server again.

可选地,请求报文中包含max-age指令,max-age指令指定文档被访问后的存活时间,这个时间是个相对值,相对的是文档第一次被请求时服务器记录的请求时间。在客户端发送的请求中包含max-age指令时,如果判定缓存资源的缓存时间数值比指定时间的数值更小,那么客户端就接收缓存的资源。当服务器返回的响应中包含max-age指令时,代理服务器将不对资源的有效性再作确认,max-age数值代表资源保存为缓存的最长时间。Optionally, the request message contains a max-age instruction, and the max-age instruction specifies the survival time after the document is accessed. This time is a relative value, which is relative to the request time recorded by the server when the document is requested for the first time. When the request sent by the client contains the max-age command, if it is determined that the cache time value of the cached resource is smaller than the specified time value, then the client receives the cached resource. When the response returned by the server contains the max-age directive, the proxy server will not confirm the validity of the resource, and the max-age value represents the maximum time that the resource is stored in the cache.

由于代理服务器的代理服务接口地址是固定的,客户端每次发送的跨域代理请求(下文进行介绍)的请求路径都会指向这一固定的代理服务接口地址,代理服务器会对跨域代理请求的请求路径进行判定,容易将此次发送的跨域代理请求认定为,与接收到的跨域代理请求是相同的请求,其请求资源相同,进而误将代理服务器缓存内容返回给客户端,或者错误地指示客户端从客户端本地缓存中获取待访问资源,导致代理服务器未能正确地根据跨域代理请求向资源服务器获取待访问资源并转发至客户端。示意性地,如果有部分跨域代理请求的对应的响应报文的响应头设置了max-age=31536000,immutable(表征强缓存)的话,后续的跨域代理请求将永远不会再到达代理服务器。Since the proxy service interface address of the proxy server is fixed, the request path of each cross-domain proxy request (described below) sent by the client will point to this fixed proxy service interface address. To determine the request path, it is easy to determine that the cross-domain proxy request sent this time is the same request as the received cross-domain proxy request, and its requested resources are the same, and then the cached content of the proxy server is returned to the client by mistake, or an error Instructs the client to obtain the resource to be accessed from the client's local cache, so that the proxy server fails to correctly obtain the resource to be accessed from the resource server according to the cross-domain proxy request and forward it to the client. Illustratively, if the response header of the corresponding response packet of some cross-domain proxy requests is set with max-age=31536000, which is immutable (representing strong caching), subsequent cross-domain proxy requests will never reach the proxy server. .

为了避免上述情况发生,可生成代理标识参数,添加至跨域代理请求中,标识跨域代理请求的唯一性,使得代理服务器在设置缓存策略的情况下,仍能够正确地根据跨域代理请求向资源服务器获取待访问资源并转发至客户端。In order to avoid the above situation, the proxy identification parameter can be generated and added to the cross-domain proxy request to identify the uniqueness of the cross-domain proxy request, so that the proxy server can still correctly send the request according to the cross-domain proxy request when the cache policy is set. The resource server obtains the resource to be accessed and forwards it to the client.

可选地,代理标识参数为时间戳参数。可选地,标识参数为随机产生的字符串。可选地,代理标识参数为随机产生的数字序列。在一种可能的实施方式中,根据时刻信息确定上述时间戳参数。例如,根据当前时刻确定时间戳参数。Optionally, the proxy identification parameter is a timestamp parameter. Optionally, the identification parameter is a randomly generated string. Optionally, the proxy identification parameter is a randomly generated number sequence. In a possible implementation manner, the above time stamp parameter is determined according to the time information. For example, the timestamp parameter is determined according to the current moment.

下面进行举例说明,浏览器向www.a.com发送HTTP请求,浏览器基于该 HTTP请求生成跨域代理请求并初次向代理服务器发送该跨域代理请求,跨域代理请求的请求路径为www.lowcode.com/proxy,即代理服务器中代理服务的接口地址。代理服务器针对此跨域代理请求生成响应报文,并设置响应报文的响应头,告诉浏览器,这个请求地址www.lowcode.com/proxy可以缓存。当浏览器向 www.b.com发送HTTP请求的时候,浏览器若还是生成请求路径为 www.lowcode.com/proxy的跨域代理请求,因代理服务器的缓存策略,浏览器便无法获得www.b.com中的网络资源。此时可在请求路径中添加代理标识参数,如时间戳参数t=4564564654564,那么跨域代理请求的请求路径为 www.lowcode.com/proxy?t=456456465456,由于加了时间戳参数,使得本次跨域代理请求与上次跨域代理请求的请求路径不相同,可强制刷新缓存,避免上述情况发生,代理服务器便会帮助浏览器获取www.b.com中的网络资源,在节省网络传输效率的同时,仍能保证跨域资源的正确访问。The following is an example, the browser sends an HTTP request to www.a.com, the browser generates a cross-domain proxy request based on the HTTP request and sends the cross-domain proxy request to the proxy server for the first time, and the request path of the cross-domain proxy request is www. lowcode.com/proxy, the interface address of the proxy service in the proxy server. The proxy server generates a response message for the cross-domain proxy request, and sets the response header of the response message to tell the browser that the request address www.lowcode.com/proxy can be cached. When the browser sends an HTTP request to www.b.com, if the browser still generates a cross-domain proxy request with the request path www.lowcode.com/proxy, the browser cannot obtain www. Web resources in b.com. At this time, the proxy identification parameter can be added to the request path, such as the timestamp parameter t=4564564654564, then the request path of the cross-domain proxy request is www.lowcode.com/proxy? t=456456465456, because the timestamp parameter is added, the request path of this cross-domain proxy request is different from the last cross-domain proxy request, and the cache can be forced to refresh to avoid the above situation, and the proxy server will help the browser to obtain www The network resources in .b.com can still ensure correct access to cross-domain resources while saving network transmission efficiency.

在示例性实施例中,位置信息包括待访问资源的第二域名信息,资源请求报文的报文发送模式可通过如下方法确定。In an exemplary embodiment, the location information includes second domain name information of the resource to be accessed, and the message sending mode of the resource request message can be determined by the following method.

获取目标应用的第一域名信息;根据第二域名信息以及第一域名信息,确定报文发送模式;若第一域名信息与第二域名信息不一致,则确定报文发送模式为跨域代理模式;若第一域名信息与第二域名信息一致,则确定报文发送模式为同域发送模式。上述第一域名信息是指目标应用的域名信息,上述第二域名信息是指待访问资源的域名信息。用户请求的业务服务器如果在本地 (localhost/127.0.0.1,局域网)或者业务域名是通过改本地hosts来实现的时候,服务器代理转发是无法请求用户本地的服务器的,此时代理请求转发功能不仅帮不上忙,还阻塞了开发流程,耽误了开发时间,通过客户端来智能判别是否开启跨域代理模式,提升开发效率,保证开发顺利进行。Obtain the first domain name information of the target application; determine the message sending mode according to the second domain name information and the first domain name information; if the first domain name information is inconsistent with the second domain name information, determine that the message sending mode is the cross-domain proxy mode; If the first domain name information is consistent with the second domain name information, it is determined that the message sending mode is the same domain sending mode. The above-mentioned first domain name information refers to the domain name information of the target application, and the above-mentioned second domain name information refers to the domain name information of the resource to be accessed. If the business server requested by the user is local (localhost/127.0.0.1, local area network) or the business domain name is implemented by changing the local hosts, the server proxy forwarding cannot request the user's local server. At this time, the proxy request forwarding function not only helps If you are not busy, it also blocks the development process and delays the development time. The client can intelligently determine whether to enable the cross-domain proxy mode, improve development efficiency, and ensure smooth development.

在一种可能的实施方式中,将待访问资源的位置信息与本地网络地址进行比较,进而确定报文发送模式。通常,本地网络地址为localhost/127.0.0.1/ 10.*.*.1/192.168.*.*,其中*代表任一数字。或者检查本地网络地址文件,检查本地网络地址文件中的网络地址是否与待访问资源的位置信息匹配。若待访问资源的位置信息与本地网络地址匹配,则确定报文发送模式为同域发送模式。若待访问资源的位置信息与本地网络地址不匹配,则确定报文发送模式为跨域代理模式。In a possible implementation manner, the location information of the resource to be accessed is compared with the local network address, so as to determine the message sending mode. Typically, the local network address is localhost/127.0.0.1/10.*.*.1/192.168.*.*, where * represents any number. Or check the local network address file to check whether the network address in the local network address file matches the location information of the resource to be accessed. If the location information of the resource to be accessed matches the local network address, it is determined that the message sending mode is the same-domain sending mode. If the location information of the resource to be accessed does not match the local network address, it is determined that the packet sending mode is the cross-domain proxy mode.

在一种可能的实施方式中,将待访问资源的位置信息与低码开发平台域名 (即代理服务器域名)进行比较,进而确定报文发送模式。若待访问资源的位置信息与低码开发平台域名匹配,则确定报文发送模式为同域发送模式。若待访问资源的位置信息与低码开发平台域名不匹配,则确定报文发送模式为跨域代理模式。在一种可能的实施方式中,响应于跨域代理模式的设置指令,设置报文发送模式为跨域代理模式。例如,响应于针对应用页面中的跨域代理按钮的点击操作,设置报文发送模式为跨域代理模式。在一个示例中,如图5所示,其示例性示出了一种设置跨域代理模式的页面示意图。用户可通过点击应用开发程序页面50中的跨域请求代理按钮51,使跨域请求代理按钮51保持在开启状态,调试预览区域52中目标应用即可通过跨域代理模式访问相应的网络资源。In a possible implementation manner, the location information of the resource to be accessed is compared with the domain name of the low-code development platform (ie, the domain name of the proxy server), and then the message sending mode is determined. If the location information of the resource to be accessed matches the domain name of the low-code development platform, it is determined that the message sending mode is the same-domain sending mode. If the location information of the resource to be accessed does not match the domain name of the low-code development platform, it is determined that the message sending mode is the cross-domain proxy mode. In a possible implementation manner, in response to the setting instruction of the cross-domain proxy mode, the packet sending mode is set to the cross-domain proxy mode. For example, in response to a click operation on the cross-domain proxy button in the application page, the message sending mode is set to the cross-domain proxy mode. In an example, as shown in FIG. 5 , it exemplarily shows a schematic diagram of a page for setting a cross-domain proxy mode. The user can click the cross-domainrequest proxy button 51 in the applicationdevelopment program page 50 to keep the cross-domainrequest proxy button 51 in the open state, and the target application in thedebugging preview area 52 can access corresponding network resources through the cross-domain proxy mode.

在另一种可能的实施方式中,若第一域名信息与第二域名信息不一致,则确定待访问资源的来源信息;若来源信息中包括第一域名信息,则确定报文发送模式为同域发送模式;若来源信息中不包括第一域名信息,则确定报文发送模式为跨域代理模式。这里以低代码开发平台为例,对上述步骤进行说明,用户在低代码开发平台中可以上传目标应用使用的数据源,由低代码开发平台将上述数据源部署至业务服务器中,低代码开发平台中也可以存储上述数据源,目标应用在发布前会先调试预览,此时数据源既可以在代理服务器中,也可以在资源服务器中,若上述来源信息表征待访问资源是来自于上述数据源(即来源信息中包括第一域名信息),虽然第二域名信息与第一域名信息不一致,但是代理服务器中具有同样的待访问资源,此时客户端可以直接向代理服务器获取待访问资源(即确定报文发送模式为同域发送模式),无需再由代理服务器向资源服务器获取待访问资源。In another possible implementation, if the first domain name information is inconsistent with the second domain name information, the source information of the resource to be accessed is determined; if the source information includes the first domain name information, it is determined that the message sending mode is the same domain Sending mode; if the source information does not include the first domain name information, it is determined that the message sending mode is the cross-domain proxy mode. Taking the low-code development platform as an example, the above steps are described. The user can upload the data source used by the target application in the low-code development platform, and the low-code development platform deploys the above data source to the business server. The low-code development platform The above data source can also be stored in the target application, and the target application will be debugged and previewed before release. At this time, the data source can be in the proxy server or the resource server. If the above source information indicates that the resource to be accessed is from the above data source (that is, the source information includes the first domain name information), although the second domain name information is inconsistent with the first domain name information, but the proxy server has the same resources to be accessed, at this time the client can directly obtain the resources to be accessed from the proxy server (ie It is determined that the message sending mode is the same-domain sending mode), and it is no longer necessary for the proxy server to obtain the resource to be accessed from the resource server.

步骤430,根据代理标识参数和位置信息生成跨域代理请求。Step 430: Generate a cross-domain proxy request according to the proxy identification parameter and the location information.

上述跨域代理请求以请求报文的方式发送,请求报文是由请求方法、请求 URI、协议版本、可选的请求首部字段和内容实体构成的。其中,请求访问服务器的类型,称为请求方法(method)。指明请求访问的资源对象的字符串,例如 /index.htm,也叫做请求URI(request-URI)。协议版本是指HTTP的版本号,用来提示客户端使用的HTTP协议功能。综合来看,资源请求报文请求内容的意思大致可以理解为:请求访问某台HTTP服务器上的/index.htm页面资源。The above cross-domain proxy request is sent in the form of a request message. The request message is composed of the request method, request URI, protocol version, optional request header fields and content entities. Among them, the type of the request to access the server is called the request method (method). A string indicating the resource object requested to access, such as /index.htm, also known as the request-URI (request-URI). The protocol version refers to the version number of HTTP, which is used to indicate the HTTP protocol function used by the client. In general, the meaning of the content of the resource request message can be roughly understood as: requesting access to the /index.htm page resource on an HTTP server.

将资源请求报文中的请求URI(也可是目标地址URL)存储到请求报文的请求头中,并替换资源请求报文中的请求URI(也可是目标地址URL)为代理服务器专门用于代理的接口地址,生成跨域代理请求。此时由于跨域代理请求的请求域名和代理服务器所属的域名是一致的,此时跨域代理请求不会受同源策略影响,资源服务器也不需要额外设置跨域资源共享(CORS)配置,就能通过代理服务器正常访问资源。Store the request URI (or the target address URL) in the resource request message into the request header of the request message, and replace the request URI (or the target address URL) in the resource request message with the proxy server for proxy use. interface address to generate cross-domain proxy requests. At this time, since the request domain name of the cross-domain proxy request is the same as the domain name to which the proxy server belongs, the cross-domain proxy request will not be affected by the same-origin policy, and the resource server does not need to set additional cross-domain resource sharing (CORS) configuration. You can access resources normally through the proxy server.

在一种可能的实施方式中,根据代理服务器的地址以及代理标识参数,生成目标地址信息;基于目标地址信息和位置信息,生成跨域代理请求。In a possible implementation manner, the target address information is generated according to the address of the proxy server and the proxy identification parameter; the cross-domain proxy request is generated based on the target address information and the location information.

上述目标地址信息是指跨域代理请求的请求路径信息。可选地,目标地址信息由代理服务器的地址以及代理标识参数构成。上述位置信息为待访问资源的位置信息,将待访问资源的位置信息存储于跨域代理请求的请求头中。The above target address information refers to the request path information of the cross-domain proxy request. Optionally, the target address information consists of the address of the proxy server and the proxy identification parameter. The above location information is the location information of the resource to be accessed, and the location information of the resource to be accessed is stored in the request header of the cross-domain proxy request.

在示例性实施例中,对代理服务器的地址以及代理标识参数进行拼接处理,生成跨域代理请求的目标地址信息。In an exemplary embodiment, the address of the proxy server and the proxy identification parameter are concatenated to generate the target address information of the cross-domain proxy request.

在示例性实施例中,将资源请求报文的接收地址信息,由待访问资源的位置信息,替换为目标地址信息;再将待访问资源的位置信息存储到资源请求报文的请求头中,生成跨域代理请求。In an exemplary embodiment, the receiving address information of the resource request message is replaced by the location information of the resource to be accessed with the target address information; and then the location information of the resource to be accessed is stored in the request header of the resource request message, Generate cross-domain proxy requests.

在一种可能的实施方式中,这里以应用开发程序为低代码开发平台为例进行说明,低代码开发平台可以被集成到其他的应用平台中,作为其他的应用平台中的一个功能。假如其他的应用平台的域名为www.x.com,那么低代码开发平台的域名为www.x.com/lowcode,低代码开发平台的代理接口地址为 www.x.com/lowcode/proxy,此时跨域代理请求的目标地址信息是由低代码开发平台的代理接口地址与上述时间戳参数进行拼接处理得到的。In a possible implementation, the application development program is taken as an example of a low-code development platform for illustration, and the low-code development platform can be integrated into other application platforms as a function of other application platforms. If the domain name of other application platforms is www.x.com, then the domain name of the low-code development platform is www.x.com/lowcode, and the proxy interface address of the low-code development platform is www.x.com/lowcode/proxy. The target address information requested by the time cross-domain proxy is obtained by splicing the proxy interface address of the low-code development platform and the above timestamp parameter.

在示例性实施例中,上述资源请求报文还包括目标应用的应用标识参数。上述应用标识参数是表征上述目标应用的唯一的编码,以区别其他应用。上述代理服务器的地址可通过如下方式确定。In an exemplary embodiment, the above resource request message further includes an application identification parameter of the target application. The above-mentioned application identification parameter is a unique code that characterizes the above-mentioned target application, so as to distinguish other applications. The address of the above proxy server can be determined as follows.

获取代理授权信息,上述代理授权信息表征各应用与各应用授权的代理服务器之间的映射关系;根据应用标识参数与代理授权信息,确定目标应用授权的目标代理服务器;相应地,对目标代理服务器的地址以及代理标识参数进行拼接处理,生成跨域代理请求的目标地址信息。上述目标代理服务器可以代理服务器集群中被目标应用授权的代理服务器,上述代理服务器集群可以是低代码开发平台的各后台服务器构成的集群,由低代码开发平台的各后台服务器提供代理服务。上述目标代理服务器的地址可以是目标代理服务器的代理接口的接口地址,上述代理接口可以是目标代理服务器的各个代理接口中被目标应用授权的代理接口。上述目标代理服务器的地址还可以是部署于目标代理服务器中运行代理服务的容器的接口地址,上述容器可以是目标代理服务器的各个容器中被目标应用授权的容器。Obtain proxy authorization information, which represents the mapping relationship between each application and the proxy server authorized by each application; determine the target proxy server authorized by the target application according to the application identification parameter and the proxy authorization information; Correspondingly, to the target proxy server The address and proxy identification parameters are spliced and processed to generate the target address information of the cross-domain proxy request. The target proxy server may be a proxy server authorized by the target application in the proxy server cluster, and the proxy server cluster may be a cluster formed by each background server of the low-code development platform, and each background server of the low-code development platform provides the proxy service. The address of the target proxy server may be an interface address of a proxy interface of the target proxy server, and the proxy interface may be a proxy interface authorized by the target application in each proxy interface of the target proxy server. The address of the target proxy server may also be an interface address of a container deployed in the target proxy server to run the proxy service, and the container may be a container authorized by the target application in each container of the target proxy server.

在一种可能的实施方式中,应用开发程序为的客户端是基于浏览器技术实现的,应用开发程序为的客户端可以是浏览器加载的前端页面。目标应用可以在浏览器中iframe标签下调试预览,若目标应用需要调用浏览器的请求发送接口发送资源获取请求,但是浏览器的请求发送接口只认可浏览器自身应用程序下的数据,并不认可浏览器中iframe标签内的数据,即目标应用的数据。In a possible implementation manner, the client for the application development program is implemented based on browser technology, and the client for the application development program may be a front-end page loaded by the browser. The target application can debug and preview under the iframe tag in the browser. If the target application needs to call the request sending interface of the browser to send a resource acquisition request, but the request sending interface of the browser only recognizes the data under the browser's own application, but does not recognize it. The data in the iframe tag in the browser, that is, the data of the target application.

在示例性实施例中,在目标应用中获取待访问资源的关联数据;对关联数据进行兼容处理,生成与关联数据内容一致的目标数据;将目标数据添加至跨域代理请求。上述兼容处理用于生成符合跨域代理请求的数据携带规则的数据,以保证资源访问成功,避免跨域代理请求中丢失资源请求报文中的关键数据信息。。In an exemplary embodiment, the associated data of the resource to be accessed is obtained in the target application; the associated data is subjected to compatibility processing to generate target data consistent with the content of the associated data; and the target data is added to the cross-domain proxy request. The above-mentioned compatibility processing is used to generate data that conforms to the data carrying rules of the cross-domain proxy request, so as to ensure successful resource access and avoid losing key data information in the resource request message in the cross-domain proxy request. .

可选地,上述兼容处理包括但不限于复制、加密、格式转换等操作。在一种可能的实施方式中,对关联数据进行复制,在程序开发应用(可以是基于浏览器实现的低代码开发平台)中生成与关联数据内容一致的目标数据,这样便可以将目标数据成功添加至跨域代理请求。Optionally, the above-mentioned compatible processing includes, but is not limited to, operations such as copying, encryption, and format conversion. In a possible implementation, the associated data is copied, and target data consistent with the content of the associated data is generated in a program development application (which may be a low-code development platform implemented based on a browser), so that the target data can be successfully Added to cross-origin proxy requests.

可选地,上述关联数据是经过加密的数据,程序开发应用以及代理服务器无法对上述关联数据进行识别,进而保证目标应用中的数据的安全性。上述关联数据可被资源服务器识别。Optionally, the above-mentioned associated data is encrypted data, and the program development application and the proxy server cannot identify the above-mentioned associated data, thereby ensuring the security of the data in the target application. The above-mentioned associated data can be recognized by the resource server.

本申请实施例对浏览器内嵌的目标应用里面涉及表单类型的数据做了兼容处理,重新在浏览器加载的程序开发应用中生成目标应用中的与待访问资源关联的目标数据,以使浏览器的请求发送接口认可,保证资源访问请求完整发送,避免丢失目标应用中的与待访问资源关联的目标数据。The embodiment of the present application performs compatibility processing on the data related to form types in the target application embedded in the browser, and regenerates the target data associated with the resource to be accessed in the target application in the program development application loaded by the browser, so that the browsing The request sending interface of the server is approved to ensure that the resource access request is sent completely and avoid losing the target data associated with the resource to be accessed in the target application.

示意性地,对上述过程举例说明,程序开发应用中内嵌的目标应用的 FormData(FormData提供一种表示表单数据的键值对的构造方式)属于iframeA (目标应用),而程序开发应用的FormData属于iframeB,目标应用只能通过程序开发应用的XMLHttpRequest方法发送资源访问请求,但是程序开发应用的 XMLHttpRequest方法只认同从程序开发应用(iframeB)创建的FormData,为保证iframeA中的FormData不丢失,程序开发应用将iframeA中的FormData 复制一份并在iframeB中重新生成,这样便使通过XMLHttpRequest方法发送的资源访问报文中携带有iframeA中的FormData的数据内容,保证成功访问资源。Schematically, to illustrate the above process, the FormData of the target application embedded in the program development application (FormData provides a way of constructing a key-value pair representing form data) belongs to iframeA (target application), while the FormData of the program development application Belonging to iframeB, the target application can only send resource access requests through the XMLHttpRequest method of the program development application, but the XMLHttpRequest method of the program development application only recognizes the FormData created from the program development application (iframeB). To ensure that the FormData in iframeA is not lost, the program development The application copies the FormData in iframeA and regenerates it in iframeB, so that the resource access message sent through the XMLHttpRequest method carries the data content of the FormData in iframeA to ensure successful resource access.

上述目标数据可以是帐号、密码、身份标识等信息。The above-mentioned target data may be information such as account numbers, passwords, and IDs.

步骤440,将跨域代理请求发送至代理服务器。Step 440, sending the cross-domain proxy request to the proxy server.

在一种可能的实施方式中,若报文发送模式为同域发送模式,则生成代理标识参数;根据代理标识参数和来源信息生成更新后的资源请求报文;将更新后的资源请求报文发送至代理服务器;其中,代理标识参数用于在代理服务器设置缓存策略的情况下,标识更新后的资源请求报文的唯一性。可选地,对来源信息表征的代理服务器的地址以及代理标识参数进行拼接处理,生成更新后的资源请求报文的目标地址信息;将资源请求报文的接收地址信息,由待访问资源的位置信息,替换为更新后的资源请求报文的目标地址信息;将待访问资源的来源信息和位置信息存储到更新后的资源请求报文的请求头中,生成更新后的资源请求报文;在目标应用中获取待访问资源的关联数据;对关联数据进行兼容处理,生成与关联数据内容一致的目标数据,上述兼容处理用于生成符合更新后的资源请求报文的数据携带规则的数据;将目标数据添加至更新后的资源请求报文。发送更新后的资源请求报文至代理服务器。In a possible implementation, if the message sending mode is the same-domain sending mode, the proxy identification parameter is generated; the updated resource request message is generated according to the proxy identification parameter and the source information; the updated resource request message is Sent to the proxy server; wherein, the proxy identification parameter is used to identify the uniqueness of the updated resource request message when the proxy server sets the cache policy. Optionally, the address of the proxy server and the proxy identification parameter represented by the source information are spliced and processed, and the target address information of the updated resource request message is generated; the receiving address information of the resource request message is determined by the location of the resource to be accessed. information, and replace it with the target address information of the updated resource request message; store the source information and location information of the resource to be accessed in the request header of the updated resource request message, and generate the updated resource request message; in Obtain the associated data of the resource to be accessed in the target application; perform compatibility processing on the associated data to generate target data consistent with the content of the associated data, and the above compatibility processing is used to generate data that conforms to the data carrying rules of the updated resource request message; Target data is added to the updated resource request message. Send the updated resource request message to the proxy server.

在示例性实施例中,获取代理授权信息,代理授权信息表征各应用与所述各应用授权的代理服务器之间的映射关系;根据应用标识参数与代理授权信息,确定目标应用授权的目标代理服务器,上述目标代理服务器包括待访问资源,上述来源信息可以表征目标代理服务器的地址;对目标代理服务器的地址以及代理标识参数进行拼接处理,生成更新后的资源请求报文的目标地址信息。In an exemplary embodiment, proxy authorization information is obtained, and the proxy authorization information represents the mapping relationship between each application and the proxy server authorized by each application; according to the application identification parameter and the proxy authorization information, the target proxy server authorized by the target application is determined The target proxy server includes resources to be accessed, and the source information can represent the address of the target proxy server; the address of the target proxy server and the proxy identification parameter are spliced to generate the updated target address information of the resource request message.

步骤450,接收代理服务器发送的响应报文。Step 450: Receive the response message sent by the proxy server.

响应报文包括待访问资源。将待访问资源发送至目标应用。The response message includes the resource to be accessed. Send the resource to be accessed to the target application.

在另一种可能的实施方式中,若报文发送模式为同域发送模式,则发送资源请求报文至资源服务器;接收资源服务器发送的响应报文,资源服务器发送的响应报文包括待访问资源。In another possible implementation, if the message sending mode is the same-domain sending mode, a resource request message is sent to the resource server; a response message sent by the resource server is received, and the response message sent by the resource server includes the to-be-accessed message resource.

在示例性实施例中,根据待访问资源,更新目标应用的调试预览页面。In an exemplary embodiment, the debug preview page of the target application is updated according to the resource to be accessed.

上述更新目标应用的调试预览页面可以是在调试预览页面中显示新的内容,也可以是目标应用的各应用页面之间进行跳转切换。The above-mentioned updating of the debug preview page of the target application may be to display new content in the debug preview page, or to switch between application pages of the target application.

可选地,上述待访问资源包括授权信息。例如,程序开发人员在目标应用的调试预览页面中输入帐号和密码后点击登录控件,触发帐号登录请求,上述帐号登录请求用于请求资源服务器发送登录授权信息;客户端在接收到授权信息后,调试预览页面由目标应用的登录页面跳转至目标应用的应用主页面。Optionally, the above resource to be accessed includes authorization information. For example, the program developer clicks the login control after inputting the account and password on the debugging preview page of the target application to trigger the account login request. The above account login request is used to request the resource server to send login authorization information; after the client receives the authorization information, The debug preview page jumps from the login page of the target application to the application main page of the target application.

可选地,上述待访问资源包括多媒体资源数据。客户端可在目标应用的调试预览页面对多媒体资源数据所加载的内容进行显示,例如播放视频、播放音频、显示文字内容等。Optionally, the resource to be accessed includes multimedia resource data. The client can display the content loaded by the multimedia resource data on the debugging preview page of the target application, such as playing video, playing audio, and displaying text content.

综上所述,本申请实施例提供的技术方案,利用服务器直接请求没有同源策略的特点,在目标应用发送的资源请求报文的基础上生成跨域代理请求,并在跨域代理请求中添加代理标识参数以标识跨域代理请求的唯一性,确保代理服务器在设置缓存策略的情况下成功接收跨域代理请求并返回正确的待访问资源,无需跨域资源共享配置,即可实现资源访问,降低资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。To sum up, the technical solutions provided by the embodiments of the present application utilize the feature that the server directly requests without the same-origin policy, and generates a cross-domain proxy request based on the resource request message sent by the target application, and generates a cross-domain proxy request in the cross-domain proxy request. Add the proxy identifier parameter to identify the uniqueness of the cross-domain proxy request, to ensure that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed under the condition of setting the cache policy. Resource access can be achieved without cross-domain resource sharing configuration , reduce the complexity of resource access, improve the efficiency of resource access, and ensure the success rate and correct rate of resource access.

请参考图6,其示出了本申请另一个实施例提供的资源访问方法的流程图。该方法可应用于计算机设备中,所述计算机设备是指具备数据计算和处理能力的电子设备,如各步骤的执行主体可以是图1所示的应用程序运行环境中的服务器20。该方法可以包括以下几个步骤(610~650)。Please refer to FIG. 6 , which shows a flowchart of a resource access method provided by another embodiment of the present application. The method can be applied to computer equipment, which refers to electronic equipment with data computing and processing capabilities. For example, the execution subject of each step may be theserver 20 in the application running environment shown in FIG. 1 . The method may include the following steps (610-650).

步骤610,接收跨域代理请求。Step 610, receiving a cross-domain proxy request.

跨域代理请求包括代理标识参数以及待访问资源的位置信息,代理标识参数用于在设置缓存策略的情况下,标识跨域代理请求的唯一性。访问资源是指目标应用在调试预览过程中请求的网络资源。The cross-domain proxy request includes the proxy identification parameter and the location information of the resource to be accessed. The proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the cache policy is set. Access resources refer to network resources requested by the target application during the debugging preview process.

可选地,由代理服务器集群中被目标应用授权的目标代理服务器接收上述跨域代理请求。可选地,由目标应用授权的代理接口接收上述跨域代理请求。可选地,由目标应用授权的运行代理服务的容器接收上述跨域代理请求。Optionally, the above-mentioned cross-domain proxy request is received by a target proxy server authorized by the target application in the proxy server cluster. Optionally, the above-mentioned cross-domain proxy request is received by a proxy interface authorized by the target application. Optionally, the container running the proxy service authorized by the target application receives the above-mentioned cross-domain proxy request.

步骤620,基于待访问资源的位置信息,生成资源获取请求。Step 620: Generate a resource acquisition request based on the location information of the resource to be accessed.

在一种可能的实施方式中,低代码开发平台服务器接收到跨域代理请求之后,从请求头中拿到资源访问报文中的待访问资源的位置信息。In a possible implementation manner, after receiving the cross-domain proxy request, the low-code development platform server obtains the location information of the resource to be accessed in the resource access message from the request header.

基于待访问资源的位置信息,重写跨域代理请求的路径(pathname),协议(protocol),端口(port)和参数(search),生成资源获取请求。Based on the location information of the resource to be accessed, rewrite the path (pathname), protocol (protocol), port (port) and parameter (search) of the cross-domain proxy request to generate a resource acquisition request.

此时利用服务器之间的请求不受浏览器同源策略的限制的特点,因为同源策略主要针对浏览器的,它是防止某个网页上的恶意脚本通过该页面的文档对象模型访问另一网页上的数据。而服务器之间的请求则没有这个限制。At this time, the request between servers is not restricted by the browser's same-origin policy, because the same-origin policy is mainly aimed at browsers. It prevents malicious scripts on a web page from accessing another page through the document object model of the page. data on web pages. Requests between servers do not have this restriction.

在示例性实施例中,上述步骤620可通过如下方式实现。In an exemplary embodiment, the above-mentionedstep 620 may be implemented in the following manner.

根据资源服务器的授权信息生成校验授权参数;基于待访问资源的位置信息,更改跨域代理请求的接收地址信息,生成资源获取请求的接收地址信息;将安全校验参数添加至跨域代理请求的请求头中,生成资源获取请求。Generate verification authorization parameters according to the authorization information of the resource server; change the receiving address information of the cross-domain proxy request based on the location information of the resource to be accessed, and generate the receiving address information of the resource acquisition request; add the security verification parameters to the cross-domain proxy request In the request header, a resource acquisition request is generated.

可选地,上述资源服务器的授权信息是预设的,上述资源服务器的授权信息中可以包括代理服务器的信息,以表示资源服务器信任代理服务器,可以为代理服务器提供相应的网络服务和网络资源。代理服务器在调用资源服务器的接口时,为向资源服务器表明身份,需要在资源获取请求的请求头中加上校验授权参数,便于资源服务器对资源获取请求进行快速安全验证,避免复杂的登录验证过程。Optionally, the authorization information of the resource server is preset, and the authorization information of the resource server may include proxy server information to indicate that the resource server trusts the proxy server and can provide the proxy server with corresponding network services and network resources. When the proxy server calls the interface of the resource server, in order to indicate its identity to the resource server, it needs to add a verification authorization parameter to the request header of the resource acquisition request, which is convenient for the resource server to quickly and securely verify the resource acquisition request and avoids complex login verification. process.

上述校验授权参数用于向所述资源服务器表征所述资源获取请求的安全性,以使所述资源服务器取消针对所述资源获取请求的验证过程。The above verification authorization parameter is used to represent the security of the resource acquisition request to the resource server, so that the resource server cancels the verification process for the resource acquisition request.

可选地,上述校验授权参数包括代理服务器的签名参数、时间戳参数、随机生成的干扰字符、应用标识参数以及秘钥参数。上述签名参数用于表征代理服务器的身份信息。上述时间戳参数用于表征资源获取请求的时刻信息并可用于表征资源获取请求的时效性。随机生成的干扰字符用于防止信息泄露。应用标识参数用于表征请求待访问资源的应用的身份信息。上述秘钥参数用于加密上述资源获取请求的信息,资源服务器可根据秘钥参数以及预设的安全规则对读取资源获取请求的信息。Optionally, the above verification authorization parameters include a signature parameter of the proxy server, a timestamp parameter, a randomly generated interference character, an application identification parameter, and a secret key parameter. The above signature parameters are used to represent the identity information of the proxy server. The above timestamp parameter is used to represent the time information of the resource acquisition request and can be used to represent the timeliness of the resource acquisition request. Randomly generated noise characters are used to prevent information leakage. The application identification parameter is used to represent the identity information of the application requesting the resource to be accessed. The above-mentioned secret key parameter is used to encrypt the information of the above-mentioned resource acquisition request, and the resource server can read the information of the resource acquisition request according to the secret key parameter and the preset security rule.

步骤630,发送资源获取请求至资源服务器。Step 630, sending a resource acquisition request to the resource server.

利用服务器之间的请求不受浏览器同源策略的限制的特点,发送资源获取请求至资源服务器。因为同源策略主要针对浏览器的,它是防止某个网页上的恶意脚本通过该页面的文档对象模型访问另一网页上的数据。而服务器之间的请求则没有这个限制。Using the feature that requests between servers are not restricted by the browser's same-origin policy, a resource acquisition request is sent to the resource server. Because the same-origin policy is mainly aimed at browsers, it prevents malicious scripts on a web page from accessing data on another web page through the document object model of the page. Requests between servers do not have this restriction.

在示例性实施例中,代理服务器与资源服务器可以是同一台服务器上的不同虚拟服务器。In an exemplary embodiment, the proxy server and the resource server may be different virtual servers on the same server.

步骤640,接收资源服务器发送的响应报文。Step 640: Receive a response message sent by the resource server.

响应报文包括待访问资源;The response message includes the resource to be accessed;

步骤650,转发响应报文至终端。Step 650, forward the response message to the terminal.

转发响应报文至终端以使所述终端根据所述待访问资源,更新所述目标应用的调试预览页面。The response message is forwarded to the terminal, so that the terminal updates the debugging preview page of the target application according to the resource to be accessed.

在一种可能的实施方式中,代理服务器接收资源服务器发送的响应报文后,可对待访问资源进行修改,并将修改后的待访问资源发送给终端。In a possible implementation manner, after receiving the response message sent by the resource server, the proxy server may modify the resource to be accessed, and send the modified resource to be accessed to the terminal.

在一种可能的实施方式中,代理服务器中存储有待访问资源,上述待访问资源的来源信息表征待访问资源的来源为目标应用向低代码开发平台发送的数据源,代理服务器接收资源请求报文(即上文实施例中更新后的资源请求报文) 后,向终端发送响应报文,代理服务器发送的响应报文包括待访问资源。In a possible implementation, the proxy server stores the resource to be accessed, the source information of the resource to be accessed represents that the source of the resource to be accessed is the data source sent by the target application to the low-code development platform, and the proxy server receives the resource request message (ie, the updated resource request message in the above embodiment), a response message is sent to the terminal, and the response message sent by the proxy server includes the resource to be accessed.

综上所述,本申请实施例提供的技术方案,利用服务器直接请求没有同源策略的特点,可在代理服务器设置缓存策略的情况下成功接收具有代理标识参数表征请求唯一性的跨域代理请求,并根据跨域代理请求生成资源获取请求以向资源服务器获取正确的待访问资源,进而将待访问资源返回给请求终端,无需跨域资源共享配置,即可实现资源访问,降低资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。To sum up, the technical solutions provided by the embodiments of the present application utilize the feature that the server directly requests without the same-origin policy, and can successfully receive a cross-domain proxy request with a proxy identifier parameter representing the uniqueness of the request when the proxy server sets a cache policy. , and generate a resource acquisition request according to the cross-domain proxy request to obtain the correct resource to be accessed from the resource server, and then return the resource to be accessed to the requesting terminal. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of resource access. , Improve the efficiency of resource access, and ensure the success rate and correct rate of resource access.

请参考图7,其示出了本申请另一个实施例提供的资源访问方法的流程图。该方法可应用于资源访问系统中,上述资源访问系统包括终端、代理服务器以及资源服务器。上述方法可以包括以下几个步骤(701-716)。Please refer to FIG. 7 , which shows a flowchart of a resource access method provided by another embodiment of the present application. The method can be applied to a resource access system, where the resource access system includes a terminal, a proxy server, and a resource server. The above method may include the following steps (701-716).

步骤701,终端显示应用页面。Step 701, the terminal displays an application page.

应用页面包括目标应用的调试预览页面。可选地,上述应用页面是程序开发应用的应用页面。The application page includes the debug preview page of the target application. Optionally, the above-mentioned application page is an application page of a program development application.

步骤702,终端响应于目标应用的资源访问指令,生成资源请求报文。Step 702, the terminal generates a resource request message in response to the resource access instruction of the target application.

资源请求报文包括待访问资源的位置信息。The resource request message includes location information of the resource to be accessed.

步骤703,终端目标应用通过请求发送接口发送资源请求报文。Step 703, the terminal target application sends a resource request message through the request sending interface.

步骤704,终端基于请求发送规则,拦截资源请求报文。Step 704, the terminal intercepts the resource request message based on the request sending rule.

步骤705,终端获取目标应用的第一域名信息。Step 705, the terminal acquires the first domain name information of the target application.

步骤706,终端根据第二域名信息以及第一域名信息,确定报文发送模式。Step 706: The terminal determines the message sending mode according to the second domain name information and the first domain name information.

若第一域名信息与第二域名信息不一致,则确定报文发送模式为跨域代理模式。If the first domain name information is inconsistent with the second domain name information, it is determined that the packet sending mode is the cross-domain proxy mode.

若第一域名信息与第二域名信息一致,则确定报文发送模式为同域发送模式。If the first domain name information is consistent with the second domain name information, it is determined that the message sending mode is the same domain sending mode.

步骤707,若资源请求报文的报文发送模式为跨域代理模式,终端则生成代理标识参数。Step 707: If the message sending mode of the resource request message is the cross-domain proxy mode, the terminal generates a proxy identification parameter.

其中,代理标识参数用于在代理服务器设置缓存策略的情况下,标识跨域代理请求的唯一性。The proxy identifier parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets the cache policy.

步骤708,终端根据代理服务器的地址以及代理标识参数,生成目标地址信息。Step 708, the terminal generates target address information according to the address of the proxy server and the proxy identification parameter.

步骤709,终端基于目标地址信息和位置信息,生成跨域代理请求。Step 709, the terminal generates a cross-domain proxy request based on the target address information and location information.

步骤710,终端对目标应用中待访问资源的关联数据进行复制,生成与关联数据内容一致的目标数据。Step 710: The terminal copies the associated data of the resource to be accessed in the target application to generate target data that is consistent with the content of the associated data.

步骤711,终端将目标数据添加至跨域代理请求。Step 711, the terminal adds target data to the cross-domain proxy request.

步骤712,将跨域代理请求发送至代理服务器。Step 712: Send the cross-domain proxy request to the proxy server.

相应地,代理服务器接收跨域代理请求。Accordingly, the proxy server receives cross-domain proxy requests.

跨域代理请求包括代理标识参数以及待访问资源的位置信息,代理标识参数用于在设置缓存策略的情况下,标识所述跨域代理请求的唯一性。The cross-domain proxy request includes a proxy identification parameter and location information of the resource to be accessed, and the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set.

步骤713,代理服务器基于待访问资源的位置信息,生成资源获取请求。Step 713: The proxy server generates a resource acquisition request based on the location information of the resource to be accessed.

步骤714,代理服务器发送资源获取请求至资源服务器。Step 714, the proxy server sends a resource acquisition request to the resource server.

相应地,资源服务器接收资源获取请求。Accordingly, the resource server receives the resource acquisition request.

步骤715,资源服务器发送响应报文至代理服务器。Step 715, the resource server sends a response message to the proxy server.

相应地,代理服务器接收资源服务器发送的响应报文。Correspondingly, the proxy server receives the response message sent by the resource server.

步骤716,代理服务器转发响应报文至终端。Step 716, the proxy server forwards the response message to the terminal.

相应地,终端接收代理服务器发送的响应报文。Correspondingly, the terminal receives the response message sent by the proxy server.

响应报文包括待访问资源。The response message includes the resource to be accessed.

在一个示例中,如图8所示,其示例性示出了跨域代理模式下资源访问流程的示意图。其中,低代码开发平台客户端80可以是浏览器前端页面;业务应用程序的实时预览页面81在低代码开发平台客户端80中显示;业务应用程序是指在低代码开发平台下用户需要进行开发的业务应用程序;业务服务器82指按照用户业务逻辑为业务应用程序提供网络服务的服务器,其域名和低代码开发平台客户端80的域名一般不会相同;低代码开发平台服务器83指为低代码开发平台客户端80提供后台服务的服务器,可在这里做业务应用程序的代理服务器,实现低代码开发平台的云端代理功能。低代码开发平台客户端80的域名是lowcode.com,相应地,低代码开发平台服务器83的域名也是owcode.com。业务服务器82的域名为business.com,业务应用程序在实际部署应用时,业务应用程序的域名与业务服务器82的域名相同,都是business.com。但此时,因业务应用程序在低代码开发平台客户端80中调试预览,所以业务应用程序的域名与低代码开发平台客户端80的域名相同,是lowcode.com。用户可在业务应用程序的实时预览页面81执行操作,进而触发业务应用程序的资源访问进程,由业务应用程序生成业务请求,以获取相应的网络资源。若业务应用程序通过低代码开发平台客户端80或者业务应用程序自己直接向业务服务器82发送业务请求,由于浏览器的同源策略限制并且业务服务器82中未设置跨域资源共享配置信息,业务服务器82的响应信息无法发送至业务应用程序。为了解决上述问题,可由低代码开发平台客户端80拦截业务应用程序发送的业务请求,更改业务请求的请求路径为低代码开发平台服务器83中的云端代理接口地址,并保存业务请求的原请求路径,生成代理请求并将代理请求发送至低代码开发平台服务器83。这样便满足浏览器的同源策略,同域名的网络请求的发送不受限制,低代码开发平台服务器83可以顺利接收代理请求。低代码开发平台服务器83接收代理请求后,基于代理请求中的保存的业务请求的原请求路径,向业务服务器发送资源获取请求。由于服务器之间的请求不存在同源策略限制,业务服务器82可顺利接收资源获取请求,并可将响应信息发送至低代码开发平台服务器83。低代码开发平台服务器83接收到响应信息后,便可将响应信息转发至低代码开发平台客户端80中的业务应用程序,这样一来,业务应用程序便可成功访问未经跨域资源共享配置的业务服务器82中的网络资源。In one example, as shown in FIG. 8 , it exemplarily shows a schematic diagram of the resource access process in the cross-domain proxy mode. The low-codedevelopment platform client 80 may be a browser front-end page; the real-time preview page 81 of the business application is displayed on the low-codedevelopment platform client 80; the business application refers to the low-code development platform where the user needs to develop The business application program; thebusiness server 82 refers to the server that provides network services for the business application program according to the user business logic, and its domain name and the domain name of the low-codedevelopment platform client 80 are generally different; the low-codedevelopment platform server 83 refers to the low-code development platform. Thedevelopment platform client 80 provides a server for background services, and can be used as a proxy server for business applications here to realize the cloud proxy function of the low-code development platform. The domain name of the low-codedevelopment platform client 80 is lowcode.com, and correspondingly, the domain name of the low-codedevelopment platform server 83 is also owcode.com. The domain name of thebusiness server 82 is business.com. When the business application program is actually deployed and applied, the domain name of the business application program is the same as the domain name of thebusiness server 82, and both are business.com. However, at this time, since the business application is debugged and previewed in the low-codedevelopment platform client 80, the domain name of the business application is the same as the domain name of the low-codedevelopment platform client 80, which is lowcode.com. The user can perform operations on the real-time preview page 81 of the service application, thereby triggering the resource access process of the service application, and the service application generates a service request to obtain corresponding network resources. If the business application directly sends a business request to thebusiness server 82 through the low-codedevelopment platform client 80 or the business application itself, due to the limitation of the browser's same-origin policy and the cross-domain resource sharing configuration information is not set in thebusiness server 82, the business server A response of 82 could not be sent to the business application. In order to solve the above problems, the low-codedevelopment platform client 80 can intercept the service request sent by the service application, change the request path of the service request to the cloud proxy interface address in the low-codedevelopment platform server 83, and save the original request path of the service request , generate a proxy request and send the proxy request to the low-codedevelopment platform server 83 . In this way, the same-origin policy of the browser is satisfied, the sending of network requests of the same domain name is not restricted, and the low-codedevelopment platform server 83 can smoothly receive the proxy request. After receiving the proxy request, the low-codedevelopment platform server 83 sends a resource acquisition request to the service server based on the original request path of the service request saved in the proxy request. Since there is no same-origin policy restriction on requests between servers, theservice server 82 can successfully receive the resource acquisition request, and can send the response information to the low-codedevelopment platform server 83 . After receiving the response information, the low-codedevelopment platform server 83 can forward the response information to the business application program in the low-codedevelopment platform client 80, so that the business application program can successfully access the non-cross-domain resource sharing configuration network resources in theservice server 82 of the

在示例性实施例中,若报文发送模式为同域发送模式,终端则发送资源请求报文至资源服务器;资源服务器发送响应报文至终端;终端接收资源服务器发送的响应报文,资源服务器发送的响应报文包括待访问资源。In an exemplary embodiment, if the message sending mode is the same-domain sending mode, the terminal sends a resource request message to the resource server; the resource server sends a response message to the terminal; the terminal receives the response message sent by the resource server, and the resource server sends a response message to the terminal. The sent response message includes the resource to be accessed.

综上所述,本申请实施例提供的技术方案,利用服务器直接请求没有同源策略的特点,在目标应用调试预览过程中发送的资源请求报文的基础上生成跨域代理请求,并在跨域代理请求中添加代理标识参数以标识跨域代理请求的唯一性,确保代理服务器在设置缓存策略的情况下成功接收跨域代理请求并返回正确的待访问资源,无需跨域资源共享配置,即可实现资源访问,降低了应用程序的调试预览的复杂度、提升了应用程序在调试预览过程中的资源访问效率,并保证资源访问的成功率与正确率。To sum up, the technical solutions provided by the embodiments of the present application utilize the feature that the server directly requests no same-origin policy, generate a cross-domain proxy request based on the resource request message sent during the debugging preview of the target application, and perform cross-domain proxy requests on the basis of the resource request message sent during the debugging preview of the target application. The proxy identifier parameter is added to the domain proxy request to identify the uniqueness of the cross-domain proxy request, to ensure that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed when the cache policy is set. It can realize resource access, reduce the complexity of debugging preview of the application, improve the resource access efficiency of the application in the process of debugging and preview, and ensure the success rate and correct rate of resource access.

另外,将本申请实施例的技术方案应用与低代码程序开发场景,通过云端代理的方式,将目标应用的资源访问请求交由低代码开发平台服务器代理,突破浏览器同源策略的限制,以请求不同源域名的资源,无需目标应用的服务器额外设置跨域资源共享(CORS)配置,即可在低代码开发平台上完成对应用程序的效果预览和接口调试,降低了应用调试门槛,加快了应用开发效率。In addition, the technical solutions of the embodiments of the present application are applied to the low-code program development scenario, and the resource access request of the target application is handed over to the low-code development platform server proxy by means of a cloud proxy, which breaks through the limitation of the browser's same-origin policy, so that the When requesting resources of different source domain names, the effect preview and interface debugging of the application can be completed on the low-code development platform without the additional configuration of cross-domain resource sharing (CORS) on the server of the target application, which reduces the threshold for application debugging and speeds up the application process. Application development efficiency.

下述为本申请装置实施例,可用于执行本申请方法实施例。对于本申请装置实施例中未披露的细节,请参照本申请方法实施例。The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

请参考图9,其示出了本申请一个实施例提供的资源访问装置的框图。该装置具有实现上述资源访问方法的功能,所述功能可以由硬件实现,也可以由硬件执行相应的软件实现。该装置可以是计算机设备,也可以设置在计算机设备中。该装置900可以包括:请求获取模块910、标识生成模块920、代理请求生成模块930、请求发送模块940及报文接收模块950。Please refer to FIG. 9 , which shows a block diagram of a resource access apparatus provided by an embodiment of the present application. The device has the function of implementing the above-mentioned resource access method, and the function can be implemented by hardware or by executing corresponding software by hardware. The apparatus may be computer equipment, or may be provided in computer equipment. Theapparatus 900 may include: arequest obtaining module 910 , anidentifier generating module 920 , a proxyrequest generating module 930 , arequest sending module 940 and amessage receiving module 950 .

请求获取模块910,用于获取目标应用发送的资源请求报文,所述资源请求报文包括待访问资源的位置信息;arequest obtaining module 910, configured to obtain a resource request message sent by the target application, where the resource request message includes location information of the resource to be accessed;

标识生成模块920,用于若所述资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数;Anidentification generation module 920, configured to generate a proxy identification parameter if the message sending mode of the resource request message is a cross-domain proxy mode;

代理请求生成模块930,用于根据所述代理标识参数和所述位置信息生成跨域代理请求;a proxyrequest generation module 930, configured to generate a cross-domain proxy request according to the proxy identification parameter and the location information;

请求发送模块940,用于将所述跨域代理请求发送至所述代理服务器;其中,所述代理标识参数用于在所述代理服务器设置缓存策略的情况下,标识所述跨域代理请求的唯一性;Arequest sending module 940, configured to send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the cross-domain proxy request when the proxy server sets a caching policy uniqueness;

报文接收模块950,用于接收所述代理服务器发送的响应报文,所述响应报文包括所述待访问资源。Themessage receiving module 950 is configured to receive a response message sent by the proxy server, where the response message includes the resource to be accessed.

在示例性实施例中,所述代理请求生成模块930包括地址生成单元、地址替换单元以及代理请求生成单元。In an exemplary embodiment, the proxyrequest generation module 930 includes an address generation unit, an address replacement unit, and a proxy request generation unit.

地址生成单元,用于对所述代理服务器的地址以及所述代理标识参数进行拼接处理,生成所述跨域代理请求的目标地址信息。The address generating unit is configured to perform splicing processing on the address of the proxy server and the proxy identification parameter to generate target address information of the cross-domain proxy request.

地址替换单元,用于将所述资源请求报文的接收地址信息,由所述待访问资源的位置信息,替换为所述目标地址信息。The address replacement unit is configured to replace the receiving address information of the resource request message with the target address information from the location information of the resource to be accessed.

代理请求生成单元,用于将所述待访问资源的位置信息存储到所述资源请求报文的请求头中,生成所述跨域代理请求。A proxy request generating unit, configured to store the location information of the resource to be accessed in the request header of the resource request message, and generate the cross-domain proxy request.

在示例性实施例中,所述资源请求报文还包括所述目标应用的应用标识参数,所述代理请求生成模块930,还包括:In an exemplary embodiment, the resource request message further includes an application identification parameter of the target application, and the proxyrequest generation module 930 further includes:

授权信息获取单元,用于获取代理授权信息,所述代理授权信息表征各应用与所述各应用授权的代理服务器之间的映射关系。The authorization information acquisition unit is configured to acquire proxy authorization information, where the proxy authorization information represents the mapping relationship between each application and the proxy server authorized by each application.

服务器确定单元,用于根据所述应用标识参数与所述代理授权信息,确定所述目标应用授权的目标代理服务器;A server determination unit, configured to determine a target proxy server authorized by the target application according to the application identification parameter and the proxy authorization information;

相应地,所述地址生成单元还用于:Correspondingly, the address generation unit is also used for:

对所述目标代理服务器的地址以及所述代理标识参数进行拼接处理,生成所述跨域代理请求的目标地址信息。The address of the target proxy server and the proxy identification parameter are concatenated to generate target address information of the cross-domain proxy request.

在示例性实施例中,所述代理请求生成模块930还包括:数据获取单元、数据兼容处理单元以及数据添加单元。In an exemplary embodiment, the proxyrequest generation module 930 further includes: a data acquisition unit, a data compatibility processing unit, and a data addition unit.

数据获取单元,用于在所述目标应用中获取所述待访问资源的关联数据。A data acquisition unit, configured to acquire the associated data of the resource to be accessed in the target application.

数据兼容处理单元,用于对所述关联数据进行兼容处理,生成与所述关联数据内容一致的目标数据,所述兼容处理用于生成符合所述跨域代理请求的数据携带规则的数据。A data compatibility processing unit, configured to perform compatibility processing on the associated data to generate target data consistent with the content of the associated data, and the compatibility processing is used to generate data that conforms to the data carrying rule requested by the cross-domain proxy.

数据添加单元,用于将所述目标数据添加至所述跨域代理请求。A data adding unit, configured to add the target data to the cross-domain proxy request.

在示例性实施例中,所述位置信息包括所述待访问资源的第二域名信息,所述装置900还包括:域名获取模块以及模式确定模块。In an exemplary embodiment, the location information includes second domain name information of the resource to be accessed, and theapparatus 900 further includes: a domain name acquisition module and a mode determination module.

域名获取模块,用于获取所述目标应用的第一域名信息;a domain name obtaining module, configured to obtain the first domain name information of the target application;

模式确定模块,用于根据所述第二域名信息以及所述第一域名信息,确定所述报文发送模式。A mode determination module, configured to determine the message sending mode according to the second domain name information and the first domain name information.

在示例性实施例中,所述模式确定模块,用于:In an exemplary embodiment, the mode determination module is configured to:

若所述第一域名信息与所述第二域名信息不一致,则确定所述报文发送模式为所述跨域代理模式;或者,若所述第一域名信息与所述第二域名信息不一致,则确定所述待访问资源的来源信息;若所述来源信息中包括所述第一域名信息,则确定所述报文发送模式为同域发送模式;若所述来源信息中不包括所述第一域名信息,则确定所述报文发送模式为所述跨域代理模式;若所述第一域名信息与所述第二域名信息一致,则确定所述报文发送模式为同域发送模式。If the first domain name information is inconsistent with the second domain name information, it is determined that the packet sending mode is the cross-domain proxy mode; or, if the first domain name information is inconsistent with the second domain name information, then determine the source information of the resource to be accessed; if the source information includes the first domain name information, determine that the message sending mode is the same domain sending mode; if the source information does not include the first domain name information If the first domain name information is consistent with the second domain name information, it is determined that the message sending mode is the same domain sending mode.

在示例性实施例中,所述请求发送模块940,还用于:In an exemplary embodiment, therequest sending module 940 is further configured to:

若所述报文发送模式为所述同域发送模式,则发送所述资源请求报文至资源服务器;If the message sending mode is the same-domain sending mode, sending the resource request message to the resource server;

所述报文接收模块950,还用于:Themessage receiving module 950 is also used for:

接收所述资源服务器发送的响应报文,所述资源服务器发送的响应报文包括所述待访问资源。A response message sent by the resource server is received, where the response message sent by the resource server includes the resource to be accessed.

在示例性实施例中,所述装置900,还包括:页面显示模块以及应用请求生成模块。In an exemplary embodiment, theapparatus 900 further includes: a page display module and an application request generation module.

页面显示模块,用于显示应用页面,所述应用页面包括所述目标应用的调试预览页面;a page display module, configured to display an application page, where the application page includes a debugging preview page of the target application;

应用请求生成模块,用于响应于所述目标应用的资源访问指令,生成所述资源请求报文。An application request generating module, configured to generate the resource request message in response to the resource access instruction of the target application.

所述请求获取模块910,包括:应用请求预发送单元以及请求拦截单元。Therequest obtaining module 910 includes: an application request pre-sending unit and a request intercepting unit.

应用请求预发送单元,用于所述目标应用通过请求发送接口发送所述资源请求报文;an application request pre-sending unit, used for the target application to send the resource request message through a request-to-send interface;

请求拦截单元,用于基于请求发送规则,拦截所述资源请求报文。The request interception unit is configured to intercept the resource request message based on the request sending rule.

综上所述,本申请实施例提供的技术方案,利用服务器直接请求没有同源策略的特点,在目标应用发送的资源请求报文的基础上生成跨域代理请求,并在跨域代理请求中添加代理标识参数以标识跨域代理请求的唯一性,确保代理服务器在设置缓存策略的情况下成功接收跨域代理请求并返回正确的待访问资源,无需跨域资源共享配置,即可实现资源访问,降低资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。To sum up, the technical solutions provided by the embodiments of the present application utilize the feature that the server directly requests without the same-origin policy, and generates a cross-domain proxy request based on the resource request message sent by the target application, and generates a cross-domain proxy request in the cross-domain proxy request. Add the proxy identifier parameter to identify the uniqueness of the cross-domain proxy request, to ensure that the proxy server successfully receives the cross-domain proxy request and returns the correct resource to be accessed under the condition of setting the cache policy. Resource access can be achieved without cross-domain resource sharing configuration , reduce the complexity of resource access, improve the efficiency of resource access, and ensure the success rate and correct rate of resource access.

请参考图10,其示出了本申请一个实施例提供的资源访问装置的框图。该装置具有实现上述资源访问方法的功能,所述功能可以由硬件实现,也可以由硬件执行相应的软件实现。该装置可以是计算机设备,也可以设置在计算机设备中。该装置1000可以包括:请求接收模块1010、资源请求生成模块1020、资源请求发送模块1030、资源接收模块1040以及报文转发模块1050。Please refer to FIG. 10 , which shows a block diagram of a resource access apparatus provided by an embodiment of the present application. The device has the function of implementing the above-mentioned resource access method, and the function can be implemented by hardware or by executing corresponding software by hardware. The apparatus may be computer equipment, or may be provided in computer equipment. Theapparatus 1000 may include: arequest receiving module 1010 , a resourcerequest generating module 1020 , a resourcerequest sending module 1030 , aresource receiving module 1040 and amessage forwarding module 1050 .

请求接收模块1010,用于接收跨域代理请求,所述跨域代理请求包括代理标识参数以及待访问资源的位置信息,所述代理标识参数用于在设置缓存策略的情况下,标识所述跨域代理请求的唯一性;Therequest receiving module 1010 is configured to receive a cross-domain proxy request, where the cross-domain proxy request includes a proxy identification parameter and location information of a resource to be accessed, and the proxy identification parameter is used to identify the cross-domain proxy when a cache policy is set. Uniqueness of domain proxy requests;

资源请求生成模块1020,用于基于所述待访问资源的位置信息,生成资源获取请求;A resourcerequest generation module 1020, configured to generate a resource acquisition request based on the location information of the resource to be accessed;

资源请求发送模块1030,用于发送所述资源获取请求至资源服务器;A resourcerequest sending module 1030, configured to send the resource acquisition request to a resource server;

资源接收模块1040,用于接收所述资源服务器发送的响应报文,所述响应报文包括所述待访问资源;Aresource receiving module 1040, configured to receive a response message sent by the resource server, where the response message includes the resource to be accessed;

报文转发模块1050,用于转发所述响应报文至终端。Themessage forwarding module 1050 is configured to forward the response message to the terminal.

在示例性实施例中,所述资源请求生成模块1020,包括参数生成单元、地址更改单元、请求生成单元。In an exemplary embodiment, the resourcerequest generating module 1020 includes a parameter generating unit, an address changing unit, and a request generating unit.

参数生成单元,用于根据所述资源服务器的授权信息生成校验授权参数;a parameter generating unit, configured to generate verification authorization parameters according to the authorization information of the resource server;

地址更改单元,用于基于所述待访问资源的位置信息,更改所述跨域代理请求的接收地址信息,生成所述资源获取请求的接收地址信息;An address changing unit, configured to change the receiving address information of the cross-domain proxy request based on the location information of the resource to be accessed, and generate the receiving address information of the resource acquisition request;

请求生成单元,用于将所述安全校验参数添加至所述跨域代理请求的请求头中,生成所述资源获取请求。A request generating unit, configured to add the security verification parameter to the request header of the cross-domain proxy request to generate the resource acquisition request.

综上所述,本申请实施例提供的技术方案,利用服务器直接请求没有同源策略的特点,可在代理服务器设置缓存策略的情况下成功接收具有代理标识参数表征请求唯一性的跨域代理请求,并根据跨域代理请求生成资源获取请求以向资源服务器获取正确的待访问资源,进而将待访问资源返回给请求终端,无需跨域资源共享配置,即可实现资源访问,降低资源访问复杂度、提升资源访问效率,并保证资源访问的成功率与正确率。To sum up, the technical solutions provided by the embodiments of the present application utilize the feature that the server directly requests without the same-origin policy, and can successfully receive a cross-domain proxy request with a proxy identifier parameter representing the uniqueness of the request when the proxy server sets a cache policy. , and generate a resource acquisition request according to the cross-domain proxy request to obtain the correct resource to be accessed from the resource server, and then return the resource to be accessed to the requesting terminal. Resource access can be achieved without cross-domain resource sharing configuration, reducing the complexity of resource access. , Improve the efficiency of resource access, and ensure the success rate and correct rate of resource access.

需要说明的是,上述实施例提供的装置,在实现其功能时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将设备的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的装置与方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that, when implementing the functions of the device provided in the above-mentioned embodiments, only the division of the above-mentioned functional modules is used as an example. The internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process thereof is detailed in the method embodiments, which will not be repeated here.

请参考图11,其示出了本申请一个实施例提供的计算机设备的结构框图。该计算机设备可以是终端。该计算机设备用于实施上述实施例中提供的终端侧的资源访问方法。具体来讲:Please refer to FIG. 11 , which shows a structural block diagram of a computer device provided by an embodiment of the present application. The computer device may be a terminal. The computer device is used to implement the resource access method on the terminal side provided in the foregoing embodiment. Specifically:

通常,计算机设备1100包括有:处理器1101和存储器1102。Generally,computer device 1100 includes:processor 1101 andmemory 1102 .

处理器1101可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器1101可以采用DSP(Digital Signal Processing,数字信号处理)、 FPGA(FieldProgrammable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器1101也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central ProcessingUnit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器 1101可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器1101还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。Theprocessor 1101 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. Theprocessor 1101 may be implemented by at least one hardware form among DSP (Digital Signal Processing, digital signal processing), FPGA (FieldProgrammable Gate Array, field programmable gate array), and PLA (Programmable Logic Array, programmable logic array). Theprocessor 1101 may also include a main processor and a coprocessor. The main processor is a processor used to process data in a wake-up state, also called a CPU (Central Processing Unit, central processing unit); A low-power processor for processing data in a standby state. In some embodiments, theprocessor 1101 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is responsible for rendering and drawing the content that needs to be displayed on the display screen. In some embodiments, theprocessor 1101 may further include an AI (Artificial Intelligence, artificial intelligence) processor, where the AI processor is used to process computing operations related to machine learning.

存储器1102可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器1102还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器1102中的非暂态的计算机可读存储介质用于存储至少一个指令,至少一段程序、代码集或指令集,所述至少一条指令、至少一段程序、代码集或指令集,且经配置以由一个或者一个以上处理器执行,以实现上述客户端侧的文本生成方法。Memory 1102 may include one or more computer-readable storage media, which may be non-transitory.Memory 1102 may also include high-speed random access memory, as well as non-volatile memory, such as one or more disk storage devices, flash storage devices. In some embodiments, a non-transitory computer-readable storage medium inmemory 1102 is used to store at least one instruction, at least one program, code set or instruction set, the at least one instruction, at least one program, code set or instruction set and configured to be executed by one or more processors to implement the client-side text generation method described above.

在一些实施例中,计算机设备1100还可选包括有:外围设备接口1103和至少一个外围设备。处理器1101、存储器1102和外围设备接口1103之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口1103相连。具体地,外围设备包括:射频电路1104、触摸显示屏1105、摄像头组件1106、音频电路1107、定位组件1108和电源1109中的至少一种。In some embodiments, thecomputer device 1100 may also optionally include: aperipheral device interface 1103 and at least one peripheral device. Theprocessor 1101, thememory 1102 and theperipheral device interface 1103 may be connected through a bus or a signal line. Each peripheral device can be connected to theperipheral device interface 1103 through a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of aradio frequency circuit 1104 , atouch display screen 1105 , acamera assembly 1106 , anaudio circuit 1107 , apositioning assembly 1108 and apower supply 1109 .

本领域技术人员可以理解,图11中示出的结构并不构成对计算机设备1100 的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。Those skilled in the art can understand that the structure shown in FIG. 11 does not constitute a limitation on thecomputer device 1100, and may include more or less components than the one shown, or combine some components, or adopt different component arrangements.

请参考图12,其示出了本申请一个实施例提供的计算机设备的结构框图。该计算机设备可以是服务器,该计算机设备用于实施上述实施例中提供的服务器侧的资源访问方法。具体来讲:Please refer to FIG. 12 , which shows a structural block diagram of a computer device provided by an embodiment of the present application. The computer device may be a server, and the computer device is used to implement the server-side resource access method provided in the above-mentioned embodiment. Specifically:

计算机设备1200包括中央处理单元(Central Processing Unit,CPU)1201、包括随机存取存储器(Random Access Memory,RAM)1202和只读存储器(Read Only Memory,ROM)1203的系统存储器1204,以及连接系统存储器1204和中央处理单元1201的系统总线1205。计算机设备1200还包括帮助计算机内的各个器件之间传输信息的基本输入/输出系统(I/O(Input/Output)系统)1206,和用于存储操作系统1213、应用程序1214和其他程序模块1212的大容量存储设备1207。Thecomputer device 1200 includes a central processing unit (CPU) 1201, asystem memory 1204 including a random access memory (RAM) 1202 and a read only memory (ROM) 1203, and a connection to thesystem memory 1204 and thesystem bus 1205 of thecentral processing unit 1201.Computer device 1200 also includes a basic input/output system (I/O (Input/Output) system) 1206 that facilitates the transfer of information between various devices within the computer, and is used to storeoperating system 1213,application programs 1214, andother program modules 1212 Themass storage device 1207.

基本输入/输出系统1206包括有用于显示信息的显示器1208和用于用户输入信息的诸如鼠标、键盘之类的输入设备1209。其中显示器1208和输入设备 1209都通过连接到系统总线1205的输入输出控制器1210连接到中央处理单元 1201。基本输入/输出系统1206还可以包括输入输出控制器1210以用于接收和处理来自键盘、鼠标、或电子触控笔等多个其他设备的输入。类似地,输入输出控制器1210还提供输出到显示屏、打印机或其他类型的输出设备。The basic input/output system 1206 includes adisplay 1208 for displaying information andinput devices 1209 such as a mouse, keyboard, etc., for user input of information. Wherein thedisplay 1208 and theinput device 1209 are connected to thecentral processing unit 1201 through the input and output controller 1210 connected to thesystem bus 1205. The basic input/output system 1206 may also include an input output controller 1210 for receiving and processing input from various other devices such as a keyboard, mouse, or electronic stylus. Similarly, input output controller 1210 also provides output to a display screen, printer, or other type of output device.

大容量存储设备1207通过连接到系统总线1205的大容量存储控制器(未示出)连接到中央处理单元1201。大容量存储设备1207及其相关联的计算机可读介质为计算机设备1200提供非易失性存储。也就是说,大容量存储设备1207 可以包括诸如硬盘或者CD-ROM(Compact Disc Read-Only Memory,只读光盘) 驱动器之类的计算机可读介质(未示出)。Mass storage device 1207 is connected tocentral processing unit 1201 through a mass storage controller (not shown) connected tosystem bus 1205 .Mass storage device 1207 and its associated computer-readable media provide non-volatile storage forcomputer device 1200 . That is, themass storage device 1207 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

不失一般性,计算机可读介质可以包括计算机存储介质和通信介质。计算机存储介质包括以用于存储诸如计算机可读指令、数据结构、程序模块或其他数据等信息的任何方法或技术实现的易失性和非易失性、可移动和不可移动介质。计算机存储介质包括RAM、ROM、EPROM(Erasable Programmable Read Only Memory,可擦除可编程只读存储器)、EEPROM(Electrically Erasable Programmable Read Only Memory,电可擦可编程只读存储器)、闪存或其他固态存储其技术,CD-ROM、DVD(Digital Video Disc,高密度数字视频光盘)或其他光学存储、磁带盒、磁带、磁盘存储或其他磁性存储设备。当然,本领域技术人员可知计算机存储介质不局限于上述几种。上述的系统存储器1204和大容量存储设备1207可以统称为存储器。Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory, Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory, Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state storage Its technology, CD-ROM, DVD (Digital Video Disc, high-density digital video disc) or other optical storage, cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art know that the computer storage medium is not limited to the above-mentioned types. Thesystem memory 1204 and themass storage device 1207 described above may be collectively referred to as memory.

根据本申请的各种实施例,计算机设备1200还可以通过诸如因特网等网络连接到网络上的远程计算机运行。也即计算机设备1200可以通过连接在系统总线1205上的网络接口单元1211连接到网络1212,或者说,也可以使用网络接口单元1211来连接到其他类型的网络或远程计算机系统(未示出)。According to various embodiments of the present application,computer device 1200 may also operate by connecting to a remote computer on a network through a network such as the Internet. That is,computer device 1200 may be connected tonetwork 1212 throughnetwork interface unit 1211 connected tosystem bus 1205, or may usenetwork interface unit 1211 to connect to other types of networks or remote computer systems (not shown).

所述存储器还包括计算机程序,该计算机程序存储于存储器中,且经配置以由一个或者一个以上处理器执行,以实现上述资源访问方法。The memory also includes a computer program stored in the memory and configured to be executed by one or more processors to implement the resource access method described above.

在示例性实施例中,还提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、所述至少一段程序、所述代码集或所述指令集在被处理器执行时以实现上述资源访问方法。In an exemplary embodiment, a computer-readable storage medium is also provided, wherein the storage medium stores at least one instruction, at least one piece of program, code set or instruction set, the at least one instruction, the at least one piece of program , the code set or the instruction set is executed by the processor to implement the above resource access method.

可选地,该计算机可读存储介质可以包括:ROM(Read Only Memory,只读存储器)、RAM(Random Access Memory,随机存取记忆体)、SSD(Solid State Drives,固态硬盘)或光盘等。其中,随机存取记忆体可以包括ReRAM(Resistance Random Access Memory,电阻式随机存取记忆体)和DRAM(Dynamic Random Access Memory,动态随机存取存储器)。Optionally, the computer-readable storage medium may include: ROM (Read Only Memory, read only memory), RAM (Random Access Memory, random access memory), SSD (Solid State Drives, solid state hard disk), or an optical disc. The random access memory may include ReRAM (Resistance Random Access Memory, resistive random access memory) and DRAM (Dynamic Random Access Memory, dynamic random access memory).

在示例性实施例中,还提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述资源访问方法。In an exemplary embodiment, there is also provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned resource access method.

应当理解的是,在本文中提及的“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。另外,本文中描述的步骤编号,仅示例性示出了步骤间的一种可能的执行先后顺序,在一些其它实施例中,上述步骤也可以不按照编号顺序来执行,如两个不同编号的步骤同时执行,或者两个不同编号的步骤按照与图示相反的顺序执行,本申请实施例对此不作限定。It should be understood that references herein to "a plurality" means two or more. "And/or", which describes the association relationship of the associated objects, means that there can be three kinds of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects are an "or" relationship. In addition, the numbering of the steps described in this document only exemplarily shows a possible execution sequence between the steps. In some other embodiments, the above steps may also be executed in different order, such as two different numbers. The steps are performed at the same time, or two steps with different numbers are performed in a reverse order to that shown in the figure, which is not limited in this embodiment of the present application.

另外,在本申请的具体实施方式中,涉及到用户信息等相关的数据,当本申请以上实施例运用到具体产品或技术中时,需要获得用户许可或者同意,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。In addition, in the specific implementation of this application, related data such as user information are involved. When the above embodiments of this application are applied to specific products or technologies, the user's permission or consent needs to be obtained, and the collection, use and Processing needs to comply with relevant laws, regulations and standards of relevant countries and regions.

以上所述仅为本申请的示例性实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above are only exemplary embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the protection of the present application. within the range.

Claims (10)

Translated fromChinese
1.一种资源访问方法,其特征在于,所述方法包括:1. A resource access method, characterized in that the method comprises:获取目标应用发送的资源请求报文,所述资源请求报文包括待访问资源的位置信息;obtaining a resource request message sent by the target application, where the resource request message includes location information of the resource to be accessed;若所述资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数;根据所述代理标识参数和所述位置信息生成跨域代理请求;将所述跨域代理请求发送至所述代理服务器;其中,所述代理标识参数用于在所述代理服务器设置缓存策略的情况下,标识所述跨域代理请求的唯一性;If the message sending mode of the resource request message is a cross-domain proxy mode, generate a proxy identification parameter; generate a cross-domain proxy request according to the proxy identification parameter and the location information; send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when the proxy server sets a caching policy;接收所述代理服务器发送的响应报文,所述响应报文包括所述待访问资源。A response message sent by the proxy server is received, where the response message includes the resource to be accessed.2.根据权利要求1所述的方法,其特征在于,所述根据所述代理标识参数和所述位置信息生成跨域代理请求,包括:2. The method according to claim 1, wherein the generating a cross-domain proxy request according to the proxy identification parameter and the location information comprises:对所述代理服务器的地址以及所述代理标识参数进行拼接处理,生成所述跨域代理请求的目标地址信息;Perform splicing processing on the address of the proxy server and the proxy identification parameter to generate the target address information of the cross-domain proxy request;将所述资源请求报文的接收地址信息,由所述待访问资源的位置信息,替换为所述目标地址信息;Replace the receiving address information of the resource request message with the target address information by the location information of the resource to be accessed;将所述待访问资源的位置信息存储到所述资源请求报文的请求头中,生成所述跨域代理请求。The location information of the resource to be accessed is stored in the request header of the resource request message, and the cross-domain proxy request is generated.3.根据权利要求2所述的方法,其特征在于,所述资源请求报文还包括所述目标应用的应用标识参数,所述对所述代理服务器的地址以及所述代理标识参数进行拼接处理,生成所述跨域代理请求的目标地址信息之前,还包括:3. The method according to claim 2, wherein the resource request message also includes an application identification parameter of the target application, and the address of the proxy server and the proxy identification parameter are spliced and processed. , before generating the target address information requested by the cross-domain proxy, further comprising:获取代理授权信息,所述代理授权信息表征各应用与所述各应用授权的代理服务器之间的映射关系;obtaining proxy authorization information, where the proxy authorization information represents the mapping relationship between each application and the proxy server authorized by each application;根据所述应用标识参数与所述代理授权信息,确定所述目标应用授权的目标代理服务器;Determine the target proxy server authorized by the target application according to the application identification parameter and the proxy authorization information;相应地,所述对所述代理服务器的地址以及所述代理标识参数进行拼接处理,生成所述跨域代理请求的目标地址信息,包括:Correspondingly, performing splicing processing on the address of the proxy server and the proxy identification parameter to generate the target address information of the cross-domain proxy request, including:对所述目标代理服务器的地址以及所述代理标识参数进行拼接处理,生成所述跨域代理请求的目标地址信息。The address of the target proxy server and the proxy identification parameter are concatenated to generate target address information of the cross-domain proxy request.4.根据权利要求2所述的方法,其特征在于,所述根据所述代理标识参数和所述位置信息生成跨域代理请求,还包括:4. The method according to claim 2, wherein the generating a cross-domain proxy request according to the proxy identification parameter and the location information further comprises:在所述目标应用中获取所述待访问资源的关联数据;Acquire the associated data of the resource to be accessed in the target application;对所述关联数据进行兼容处理,生成与所述关联数据内容一致的目标数据,所述兼容处理用于生成符合所述跨域代理请求的数据携带规则的数据;performing compatibility processing on the associated data to generate target data consistent with the content of the associated data, and the compatibility processing is used to generate data that conforms to the data carrying rules requested by the cross-domain proxy;将所述目标数据添加至所述跨域代理请求。The target data is added to the cross-domain proxy request.5.根据权利要求1所述的方法,其特征在于,所述位置信息包括所述待访问资源的第二域名信息,所述方法还包括:5. The method according to claim 1, wherein the location information comprises second domain name information of the resource to be accessed, and the method further comprises:获取所述目标应用的第一域名信息;obtaining the first domain name information of the target application;若所述第一域名信息与所述第二域名信息不一致,则确定所述报文发送模式为所述跨域代理模式;或者,若所述第一域名信息与所述第二域名信息不一致,则确定所述待访问资源的来源信息;若所述来源信息中包括所述第一域名信息,则确定所述报文发送模式为同域发送模式;若所述来源信息中不包括所述第一域名信息,则确定所述报文发送模式为所述跨域代理模式。If the first domain name information is inconsistent with the second domain name information, it is determined that the packet sending mode is the cross-domain proxy mode; or, if the first domain name information is inconsistent with the second domain name information, then determine the source information of the resource to be accessed; if the source information includes the first domain name information, determine that the message sending mode is the same domain sending mode; if the source information does not include the first domain name information If the domain name information is present, it is determined that the message sending mode is the cross-domain proxy mode.若所述第一域名信息与所述第二域名信息一致,则确定所述报文发送模式为同域发送模式。If the first domain name information is consistent with the second domain name information, it is determined that the message sending mode is the same-domain sending mode.6.根据权利要求1至5任一项所述的方法,其特征在于,所述获取资源请求报文之前,还包括:6. The method according to any one of claims 1 to 5, wherein before the obtaining the resource request message, further comprising:显示应用页面,所述应用页面包括所述目标应用的调试预览页面;displaying an application page, where the application page includes a debugging preview page of the target application;响应于所述目标应用的资源访问指令,生成所述资源请求报文。The resource request message is generated in response to the resource access instruction of the target application.所述获取资源请求报文,包括:The obtaining resource request message includes:所述目标应用通过请求发送接口发送所述资源请求报文;The target application sends the resource request message through a request-to-send interface;基于请求发送规则,拦截所述资源请求报文。The resource request message is intercepted based on the request to send rule.7.一种资源访问方法,其特征在于,所述方法包括:7. A resource access method, characterized in that the method comprises:接收跨域代理请求,所述跨域代理请求包括代理标识参数以及待访问资源的位置信息,所述代理标识参数用于在设置缓存策略的情况下,标识所述跨域代理请求的唯一性;receiving a cross-domain proxy request, where the cross-domain proxy request includes a proxy identification parameter and location information of the resource to be accessed, and the proxy identification parameter is used to identify the uniqueness of the cross-domain proxy request when a cache policy is set;基于所述待访问资源的位置信息,生成资源获取请求;generating a resource acquisition request based on the location information of the resource to be accessed;发送所述资源获取请求至资源服务器;sending the resource acquisition request to a resource server;接收所述资源服务器发送的响应报文,所述响应报文包括所述待访问资源;receiving a response message sent by the resource server, where the response message includes the resource to be accessed;转发所述响应报文至终端。Forward the response message to the terminal.8.根据权利要求7所述的方法,其特征在于,所述基于所述待访问资源的位置信息,生成资源获取请求,包括:8. The method according to claim 7, wherein the generating a resource acquisition request based on the location information of the resource to be accessed comprises:根据所述资源服务器的授权信息生成校验授权参数;Generate verification authorization parameters according to the authorization information of the resource server;基于所述待访问资源的位置信息,更改所述跨域代理请求的接收地址信息,生成所述资源获取请求的接收地址信息;Based on the location information of the resource to be accessed, changing the receiving address information of the cross-domain proxy request, and generating the receiving address information of the resource acquisition request;将所述安全校验参数添加至所述跨域代理请求的请求头中,生成所述资源获取请求。The security verification parameter is added to the request header of the cross-domain proxy request to generate the resource acquisition request.9.一种资源访问装置,其特征在于,所述装置包括:9. A resource access device, characterized in that the device comprises:请求获取模块,用于获取目标应用发送的资源请求报文,所述资源请求报文包括待访问资源的位置信息;a request acquisition module, configured to acquire a resource request message sent by the target application, where the resource request message includes location information of the resource to be accessed;标识生成模块,用于若所述资源请求报文的报文发送模式为跨域代理模式,则生成代理标识参数;an identification generation module, configured to generate a proxy identification parameter if the message sending mode of the resource request message is a cross-domain proxy mode;代理请求生成模块,用于根据所述代理标识参数和所述位置信息生成跨域代理请求;a proxy request generation module, configured to generate a cross-domain proxy request according to the proxy identification parameter and the location information;请求发送模块,用于将所述跨域代理请求发送至所述代理服务器;其中,所述代理标识参数用于在所述代理服务器设置缓存策略的情况下,标识所述跨域代理请求的唯一性;A request sending module, configured to send the cross-domain proxy request to the proxy server; wherein the proxy identification parameter is used to identify the unique cross-domain proxy request when the proxy server sets a caching policy sex;报文接收模块,用于接收所述代理服务器发送的响应报文,所述响应报文包括所述待访问资源。A message receiving module, configured to receive a response message sent by the proxy server, where the response message includes the resource to be accessed.10.一种资源访问装置,其特征在于,所述装置包括:10. A resource access device, characterized in that the device comprises:请求接收模块,用于接收跨域代理请求,所述跨域代理请求包括代理标识参数以及待访问资源的位置信息,所述代理标识参数用于在设置缓存策略的情况下,标识所述跨域代理请求的唯一性;A request receiving module, configured to receive a cross-domain proxy request, where the cross-domain proxy request includes a proxy identification parameter and location information of the resource to be accessed, and the proxy identification parameter is used to identify the cross-domain proxy when a cache policy is set Uniqueness of proxy requests;资源请求生成模块,用于基于所述待访问资源的位置信息,生成资源获取请求;a resource request generation module, configured to generate a resource acquisition request based on the location information of the resource to be accessed;资源请求发送模块,用于发送所述资源获取请求至资源服务器;a resource request sending module, configured to send the resource acquisition request to a resource server;资源接收模块,用于接收所述资源服务器发送的响应报文,所述响应报文包括所述待访问资源;a resource receiving module, configured to receive a response message sent by the resource server, where the response message includes the resource to be accessed;报文转发模块,用于转发所述响应报文至终端。A message forwarding module, configured to forward the response message to the terminal.
CN202111664836.8A2021-04-162021-12-31 Resource access method and deviceActiveCN115225707B (en)

Applications Claiming Priority (2)

Application NumberPriority DateFiling DateTitle
CN20211041176542021-04-16
CN2021104117652021-04-16

Publications (2)

Publication NumberPublication Date
CN115225707Atrue CN115225707A (en)2022-10-21
CN115225707B CN115225707B (en)2025-05-09

Family

ID=83606139

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202111664836.8AActiveCN115225707B (en)2021-04-162021-12-31 Resource access method and device

Country Status (1)

CountryLink
CN (1)CN115225707B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115567328A (en)*2022-12-062023-01-03杭州菲助科技有限公司Secure encrypted transmission method, device and application of video resource address
CN115988080A (en)*2023-03-222023-04-18北京首信科技股份有限公司Micro service resource calling method and system based on proxy middleware
CN116192672A (en)*2022-12-162023-05-30中国联合网络通信集团有限公司Script viewing method and related equipment
CN116506503A (en)*2023-04-132023-07-28平安银行股份有限公司Method for completing business function by using back-end service, computer equipment and computer readable storage medium
CN116647546A (en)*2023-06-072023-08-25政采云有限公司Flutter_web running method, device, equipment and medium
CN116684468A (en)*2023-08-022023-09-01腾讯科技(深圳)有限公司Data processing method, device, equipment and storage medium
CN116737598A (en)*2023-08-142023-09-12北京国电通网络技术有限公司Page debugging method, device, electronic equipment and computer readable medium
CN117459802A (en)*2023-11-082024-01-26天翼数字生活科技有限公司 A video stream cross-domain playback method, system, device and medium
CN119807150A (en)*2024-11-192025-04-11苏州空天信息研究院 A cross-domain sharing system and method for earth data resources
WO2025113567A1 (en)*2023-12-012025-06-05天翼云科技有限公司Sdwan-based cross-border transmission optimization method

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102447726A (en)*2010-10-152012-05-09中兴通讯股份有限公司page access method and system
CN104410711A (en)*2014-12-152015-03-11北京国双科技有限公司Cross-domain network resource request method and device for client
EP3343878A1 (en)*2016-12-292018-07-04Synology IncorporatedCross-domain communication methods and proxy servers using the same
CN111666514A (en)*2020-04-282020-09-15平安科技(深圳)有限公司Data processing method and device for realizing cross-domain request at webpage end and related equipment
CN112261111A (en)*2020-10-162021-01-22蜂助手股份有限公司Method and system for realizing cross-domain access of browser in application program

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102447726A (en)*2010-10-152012-05-09中兴通讯股份有限公司page access method and system
CN104410711A (en)*2014-12-152015-03-11北京国双科技有限公司Cross-domain network resource request method and device for client
EP3343878A1 (en)*2016-12-292018-07-04Synology IncorporatedCross-domain communication methods and proxy servers using the same
CN111666514A (en)*2020-04-282020-09-15平安科技(深圳)有限公司Data processing method and device for realizing cross-domain request at webpage end and related equipment
CN112261111A (en)*2020-10-162021-01-22蜂助手股份有限公司Method and system for realizing cross-domain access of browser in application program

Cited By (15)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN115567328A (en)*2022-12-062023-01-03杭州菲助科技有限公司Secure encrypted transmission method, device and application of video resource address
CN115567328B (en)*2022-12-062023-03-14杭州菲助科技有限公司Secure encryption transmission method, device and application of video resource address
CN116192672A (en)*2022-12-162023-05-30中国联合网络通信集团有限公司Script viewing method and related equipment
CN115988080A (en)*2023-03-222023-04-18北京首信科技股份有限公司Micro service resource calling method and system based on proxy middleware
CN116506503A (en)*2023-04-132023-07-28平安银行股份有限公司Method for completing business function by using back-end service, computer equipment and computer readable storage medium
CN116647546A (en)*2023-06-072023-08-25政采云有限公司Flutter_web running method, device, equipment and medium
CN116684468A (en)*2023-08-022023-09-01腾讯科技(深圳)有限公司Data processing method, device, equipment and storage medium
CN116684468B (en)*2023-08-022023-10-20腾讯科技(深圳)有限公司Data processing method, device, equipment and storage medium
CN116737598A (en)*2023-08-142023-09-12北京国电通网络技术有限公司Page debugging method, device, electronic equipment and computer readable medium
CN116737598B (en)*2023-08-142023-10-20北京国电通网络技术有限公司 Page debugging method, device, electronic device and computer-readable medium
CN117459802A (en)*2023-11-082024-01-26天翼数字生活科技有限公司 A video stream cross-domain playback method, system, device and medium
WO2025098216A1 (en)*2023-11-082025-05-15天翼视联科技有限公司Cross-domain playing method and system for video stream, and device and medium
CN117459802B (en)*2023-11-082025-09-12天翼视联科技有限公司 Method, system, device and medium for cross-domain video streaming playback
WO2025113567A1 (en)*2023-12-012025-06-05天翼云科技有限公司Sdwan-based cross-border transmission optimization method
CN119807150A (en)*2024-11-192025-04-11苏州空天信息研究院 A cross-domain sharing system and method for earth data resources

Also Published As

Publication numberPublication date
CN115225707B (en)2025-05-09

Similar Documents

PublicationPublication DateTitle
CN115225707B (en) Resource access method and device
US10798127B2 (en)Enhanced document and event mirroring for accessing internet content
US10212173B2 (en)Deterministic reproduction of client/server computer state or output sent to one or more client computers
US9544329B2 (en)Client/server security by an intermediary executing instructions received from a server and rendering client application instructions
US9864671B1 (en)Systems and methods of live experimentation on content provided by a web site
US11120107B2 (en)Managing content delivery to client devices
US10474729B2 (en)Delayed encoding of resource identifiers
WO2017129016A1 (en)Resource access method, apparatus and system
CN116584086A (en) Inline File Download Control in Remote Browser Isolation System
US10951682B2 (en)Systems and methods for accessing multiple resources via one identifier
Singh et al.Practical end-to-end web content integrity
US11314834B2 (en)Delayed encoding of resource identifiers
CN115270023A (en)Page data caching method and related equipment thereof
CN103971059B (en)Cookie local storage and usage method
CN115098810A (en)Page data caching method and related equipment thereof
CN114157568B (en) A browser secure access method, device, equipment and storage medium
US12425489B2 (en)Inserting and replacing placeholders in resource code
CN112836186A (en) A kind of page control method and device
CN105991599B (en)JSONP requesting method and device
US11475122B1 (en)Mitigating malicious client-side scripts
HK40085236A (en)Document encryption method and device, electronic equipment, storage medium, program product
CN119603027A (en) Authentication method and device, electronic device, and computer-readable storage medium
WO2024249152A1 (en)Inserting and replacing placeholders in resource code
CN115935304A (en)Document encryption method and device, electronic equipment, storage medium and program product
HK40044651A (en)A page control method and device

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp