CN111695072A - Method and device for converting HTTP (hyper text transport protocol) request - Google Patents

Method and device for converting HTTP (hyper text transport protocol) request Download PDF

Info

Publication number
CN111695072A
CN111695072A CN201910184472.XA CN201910184472A CN111695072A CN 111695072 A CN111695072 A CN 111695072A CN 201910184472 A CN201910184472 A CN 201910184472A CN 111695072 A CN111695072 A CN 111695072A
Authority
CN
China
Prior art keywords
http request
content
type
converting
original
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.)
Pending
Application number
CN201910184472.XA
Other languages
Chinese (zh)
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.)
NIO Co Ltd
Original Assignee
NIO 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 NIO Co Ltd filed Critical NIO Co Ltd
Priority to CN201910184472.XA priority Critical patent/CN111695072A/en
Publication of CN111695072A publication Critical patent/CN111695072A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Abstract

According to one or more embodiments of the invention, a method for converting an HTTP request is disclosed, which includes receiving an original HTTP request, reading content of the original HTTP request, and storing parameters and parameter values in the original HTTP request as common information in a global object instance.

Description

Method and device for converting HTTP (hyper text transport protocol) request
Technical Field
Embodiments of the present invention relate to network technologies, and more particularly, to a method and apparatus for converting an HTTP request.
Background
The HTTP Protocol (hypertext Transfer Protocol) is a Transfer Protocol for transferring hypertext from a web server to a local browser. The HTTP protocol works in a client-server architecture, the browser serves as an HTTP client to send a request to an HTTP server, namely a WEB server, through a URL, and the Web server sends response information to the client according to the received request. HTTP allows the transfer of any type of data object. The Type being transferred is tagged by Content-Type. An HTTP request may include a request header (header) and a request body (body). The request header contains several attributes, in the format "attribute name: attribute value ", the server obtains the information of the client according to the attribute value. The requestor and the URL may carry data for a number of request parameters.
Disclosure of Invention
According to one or more embodiments of the invention, a method for converting an HTTP request is disclosed, which includes receiving an original HTTP request, reading content of the original HTTP request, and storing parameters and parameter values in the original HTTP request as common information in a global object instance.
Optionally, parameters and parameter values in the Header and/or Body in the original HTTP request as common information are stored in a global object instance.
Optionally, the method further includes determining a Content-Type of the HTTP request, and converting the Content-Type to adapt to a current service system architecture.
Optionally, the method further comprises converting the Content-Type to application/json.
Optionally, the method further comprises translating the naming of the business data in the original HTTP request to adapt to the current service system architecture.
An apparatus for converting an HTTP request includes means for receiving an original HTTP request, means for reading content of the original HTTP request, and means for storing parameters and parameter values in the original HTTP request as common information in a global object instance.
In some embodiments, parameters and parameter values in Header and/or Body in the original HTTP request as common information are stored in a global object instance.
In some embodiments, the means for converting the HTTP request further comprises means for determining a Content-Type of the HTTP request, and means for converting the Content-Type to accommodate a current service system architecture.
In some embodiments, the means for converting the HTTP request further comprises means for converting the Content-Type to application/json.
In some embodiments, the means for translating the HTTP request further comprises means for translating the naming of the traffic data in the original HTTP request to fit the current service system architecture.
In some embodiments, disclosed herein is a computer-readable storage medium having instructions thereon that, when executed, cause a computing device to perform a method in accordance with the operational steps of the various embodiments herein.
Drawings
The foregoing and other features and advantages of various embodiments of the present invention will be apparent from the following detailed description taken in conjunction with the accompanying drawings, in which like elements are numbered alike in the figures.
Fig. 1 is a flowchart illustrating a method of converting an HTTP request according to one embodiment of the present invention.
Fig. 2 is a flowchart illustrating a method of converting an HTTP request according to another embodiment of the present invention.
Fig. 3 is a flowchart illustrating a method of converting an HTTP request according to another embodiment of the present invention.
FIG. 4 is an example computing device suitable for use with the present invention, in accordance with various embodiments.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of example embodiments of the invention. However, it will be understood by those of ordinary skill in the art that the example embodiments described herein may be practiced without these specific details. In other instances, well-known methods, procedures, and components have not been described in detail so as not to obscure the example embodiments described herein. The following description uses the phrases "in an embodiment" or "in an example," which may each refer to one or more of the same or different embodiments. The terminology used herein is for the purpose of better explaining the principles of various embodiments, practical applications, improvements in technology, or enabling one of ordinary skill in the art to understand and practice the embodiments disclosed herein.
One or more embodiments of the invention may be a computing system, method and computer program product. The computer program product may include a computer-readable storage medium (or media) on which computer-readable program instructions may be stored for causing a processor to perform embodiments of the present invention.
The microservice architecture uses a suite of servlets to develop a single application, each service capable of running in a respective process and communicating using a lightweight mechanism, such as an HTTP API. These services are built based on business capabilities and can be deployed independently through automated deployment mechanisms. Since there may be call relationships between the microservices, when an interface of one microservice changes, it may result in an adjustment of the interface of another microservice. In addition, the HTTP request methods of various micro services are different, for example, the Content-Type of the HTTP request used by java is application/x-www-form-url; the Content-Type of the HTTP request used by the net is application/json. Net is usually named using the Pascal grammar. These differences can increase the complexity of java and net micro-services invoking each other. Some embodiments of the invention provide a method of translating HTTP requests that takes into account differences between different service invocations. On the other hand, in order to reduce the calling cost of different interfaces, some embodiments of the present invention consider the development and maintenance efficiency of extracting common content information of different locations of an HTTP request to be collected for providing services.
Fig. 1 is a flowchart illustrating a method of converting an HTTP request according to one embodiment of the present invention.
In step 110, an original HTTP request is received. In step 120, the content of the original HTTP request is read. In step 130, the HTTP request is translated. In step 140, the common information is extracted. As described above, the Content-Type of the HTTP request used by java is application/x-www-form-url; the Content-Type of the HTTP request used by the net is application/json, and this difference increases the complexity of java and net microservices invoking each other. Thus, some embodiments of the invention propose to convert Content-Type to accommodate the current service system architecture. Net is usually named using the camel grammar, and some embodiments of the invention propose to translate the naming of the traffic data in the original HTTP request to adapt to the current service system architecture. In other embodiments, the parameters and parameter values in the original HTTP request as common information are stored in a global object instance, thereby improving development and maintenance efficiency of the service.
Fig. 2 is a flowchart illustrating a method of converting an HTTP request according to another embodiment of the present invention. The steps illustrated in fig. 2 are a specific example of step 130 in fig. 1. In step 131, the Content-Type of the HTTP request is determined. In step 132, the Content-Type is converted to accommodate the current service system architecture. Optionally, in step 133, the naming of the business data in the original HTTP request is translated to suit the current service system architecture.
The Content-Type is a Header field of the HTTP request, and is used to specify the Content Type by which the message body of the request is encoded. The Content-Type in the Header may be (1) application/x-www-form-url encoded, in which format the data is encoded as name/value pairs, which belongs to a standard encoding format; (2) application/json, in which data is sent to the server in json form.
In one embodiment of the invention, the Content-Type of the HTTP request is judged, and the Content-Type is converted to adapt to the current service system architecture. In one example, when the Content-Type is determined to be application/x-www-form-url, the Content-Type is converted to application/json. Thus, other types of requests can be translated within the aspnetcore pipe into application/json-style requests applicable to the. net.
One specific example is described below. The initiated HTTP request contains the Header:
a)Content-Type:application/x-www-form-urlencoded
b)token:2.0 IamdGnOCjyKEh++6NDM7rRSbRAiqtNi3RuUZmNcRNqc=
c)mobileinfo:″{\″os_lang\″:\″zh-Hans-CN\″,\″channel\″:\″unknow\″,\″app_version\″:\″3.2.5\″,\″device_brand\″:\″iPhoneX\″,\″os_timezone\″:\″Asia/Shanghai\″,\″deviceId\″:\″iPhone10,3\″,\″network_type\″:\″Cellular\″,\″device_type\″:\″ios\″,\″geo\″:{\″longitude\″:113.76949164293528,\″latitude\″:34.74706612350549},\″userId\″:\″256758319\″,\″device_id\″:\″A90E478F-9CAD-4E4C-BE64-0F7A6DF40BB1\″,\″react_version\″:\″0.0.3\″,\″ip_address\″:\″0.0.0.0\″,\″device_model\″:\″Apple\″}″
d)pinpoint-TraceID:mer-gateway-prod-01^1546072006836^11935115
the HTTP request contains Body:
a)loginAccount:123456789
b)appName:nio_app_client
c)application:50105
d)versionCode:1.1
e)data:″{\″SpuCode\″:\″TG20190114000008\″}″
in this example, Body is represented in the format of "x-www-form-url encoded". After conversion, business data of Body expressed in application/json form: "SpuCode \ includes: \\ "TG 20190114000008 \". The content of the service data, the initials of which are converted into the capital of the net habit, such as: "SpuCode" is converted to "SpuCode".
Fig. 3 is a flowchart illustrating a method of converting an HTTP request according to another embodiment of the present invention. The steps illustrated in fig. 3 are a specific example of step 140 in fig. 1. In step 141, parameters to be common information are determined in the HTTP request. In step 142, the common information is extracted and stored to the global object. In this embodiment, the parameters and parameter values in the original HTTP request as common information are stored in a global object instance. Optionally, parameters and parameter values in the Header and/or Body in the original HTTP request as common information are stored in a global object instance.
Taking the above specific example as an example, parameters mobileinfo, token, appName, versionCode may be selected as the common information, for example. In some embodiments, after the HTTP request passes through, for example, HTTP request translation middleware, its common information is extracted into the global object instance. The following is an example of storing public information in the global object baseRequest.
IBaseRequest baseRequest=context.RequestServices.GetService<IBaseRequest>();
// obtaining baseRequest Global instance
baseRequest.Application=req.Form[″application″];
baseRequest.AppName=req.Query[″appname″];
baseRequest.LoginAccount=req.Query[″loginaccount″];
baseRequest.VersionCode=req.Form[″versioncode″];
baseRequest.|Token=req.Headers[″token″];
baseRequest.Mobileinfo=req.Headers[″mobileinfo″];
// assigning common information within HTTP request
In some embodiments, the HTTP request data is stored into baseRequest, which is one global object instance that survives the HTTP request lifecycle.
Those skilled in the art will appreciate that middleware can be constructed to perform the various operations described above. For example, the original HTTP request may be intercepted by using middleware, and after the original HTTP request is read, the common information in the original HTTP request is placed in the baseRequest. Thereafter, the middleware finds the service data and rewrites the service data in the form of a Stream (Stream) into Body of the HTTP request. Finally, the middleware rewrites the Content-Type of the HTTP request to convert it to application/json. It will also be understood by those skilled in the art that for an aspnetcore framework based net microservice, di (dependency injection) injection may be used as a design model for baseRequest. When the public information is needed to be used in other places, the baseRequest can be directly acquired in a DI mode due to DI injection.
Various operations described above may be described as multiple discrete operations in turn, however, the order of description should not be construed as to imply that these operations are necessarily order dependent.
An example of a computing device that implements the functionality associated with the flowcharts shown in fig. 1-3 will be described below. FIG. 4 illustrates an example computing device 500 suitable for use with the invention, in accordance with various embodiments. FIG. 4 illustrates an example computing device 400 suitable for use with the invention in accordance with various embodiments. For example, the example computing device 400 may be adapted to perform the various embodiments described herein.
As shown, computing device 400 may include one or more processors 410, each having one or more processor cores. Processor 410 may include any type of single-core or multi-core processor. Each processor may include a Central Processing Unit (CPU) and one or more levels of cache.
The computing device 400 may include storage 420, and the storage 420 may be any type of temporary and/or permanent storage including, but not limited to, volatile and non-volatile memory, optical, magnetic, and/or solid state memory. Volatile memory may include, but is not limited to, static and/or dynamic random access memory. Non-volatile memory may include, but is not limited to, erasable programmable read only memory, phase change memory, resistive memory, and the like. In some examples, storage 420 includes: a magnetic hard disk, a solid state hard drive, a semiconductor memory device, a Read Only Memory (ROM), flash memory, or any other computer readable storage medium capable of storing program instructions or digital information. Storage 420 may also store program modules, which may be collections of various programming instructions, that implement the flow diagrams illustrated in figures 1-3 or the logic of the methods in various embodiments of the present invention. The data information and the program information in the storage 420 may be distributed as a computer program product in a computer readable storage medium or may be received from a distribution server via a communication unit.
Computing device 400 may also include input/output (I/O) devices 440, such as a display, a keyboard, and so forth. Computing device 400 may also include a communication unit 430, such as a network interface card, a modem, a wireless communication transceiver, or the like. The communication unit 430 provides for communication with other data processing systems or devices. The various components of computing device 400 may be coupled to one another via a system bus 450.
In some embodiments, disclosed herein is an apparatus for translating an HTTP request, comprising means for receiving an original HTTP request, means for reading content of the original HTTP request, and means for storing parameters and parameter values in the original HTTP request as common information in a global object instance.
In some embodiments, parameters and parameter values in Header and/or Body in the original HTTP request as common information are stored in a global object instance.
In some embodiments, the means for converting the HTTP request further comprises means for determining a Content-Type of the HTTP request, and means for converting the Content-Type to accommodate a current service system architecture.
In some embodiments, the means for converting the HTTP request further comprises means for converting the Content-Type to application/json.
In some embodiments, the means for translating the HTTP request further comprises means for translating the naming of the traffic data in the original HTTP request to fit the current service system architecture.
In some embodiments, disclosed herein is a computer-readable storage medium having instructions thereon that, when executed, cause a computing device to perform a method in accordance with the operational steps of the various embodiments herein.
The description of one or more embodiments of the present invention is not intended to be exhaustive or to limit the scope of the embodiments to the precise forms disclosed or claimed herein. Modifications and variations are possible in light of the above teachings or may be acquired from practice of various implementations of various embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the invention.

Claims (11)

1. A method of translating HTTP requests, comprising,
the original HTTP request is received and,
the content of the original HTTP request is read, and,
storing parameters and parameter values in the original HTTP request as common information in a global object instance.
2. Method according to claim 1, characterized in that parameters and parameter values in Header and/or Body as common information in the original HTTP request are stored in a global object instance.
3. The method of claim 1, further comprising,
determines the Content-Type of the HTTP request,
and converting the Content-Type to adapt to the current service system architecture.
4. The method of claim 3, further comprising,
and converting the Content-Type into application/json.
5. The method of claim 2, further comprising,
the naming of the business data in the original HTTP request is transformed to fit the current service system architecture.
6. An apparatus for translating an HTTP request, comprising,
means for receiving an original HTTP request,
means for reading the content of the original HTTP request, and,
means for storing parameters and parameter values in the original HTTP request as common information in a global object instance.
7. The apparatus of claim 6,
parameters and parameter values in Header and/or Body in the original HTTP request as common information are stored in the global object instance.
8. The apparatus of claim 6, further comprising,
means for determining a Content-Type of the HTTP request,
means for converting the Content-Type to accommodate a current service system architecture.
9. The apparatus of claim 8, further comprising,
means for converting the Content-Type to application/json.
10. The apparatus of claim 8, further comprising,
means for translating the naming of the business data in the original HTTP request to accommodate current serving system architecture.
11. A computer-readable storage medium having instructions thereon that, when executed, cause a computing device to perform the method of any of claims 1 to 5.
CN201910184472.XA 2019-03-12 2019-03-12 Method and device for converting HTTP (hyper text transport protocol) request Pending CN111695072A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910184472.XA CN111695072A (en) 2019-03-12 2019-03-12 Method and device for converting HTTP (hyper text transport protocol) request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910184472.XA CN111695072A (en) 2019-03-12 2019-03-12 Method and device for converting HTTP (hyper text transport protocol) request

Publications (1)

Publication Number Publication Date
CN111695072A true CN111695072A (en) 2020-09-22

Family

ID=72474809

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910184472.XA Pending CN111695072A (en) 2019-03-12 2019-03-12 Method and device for converting HTTP (hyper text transport protocol) request

Country Status (1)

Country Link
CN (1) CN111695072A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112822237A (en) * 2020-12-28 2021-05-18 北京奇艺世纪科技有限公司 Network request transmission method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103064690A (en) * 2012-12-16 2013-04-24 互动在线(北京)科技有限公司 Development framework based on Android operating system and execution method thereof
CN103763394A (en) * 2014-02-10 2014-04-30 赛特斯信息科技股份有限公司 System and method for achieving access and callout of EJB through ESB
US8965952B1 (en) * 2009-09-22 2015-02-24 Cellco Partnership Processing service requests of multiple types on a common communication port for a service that accepts only one type
CN105991564A (en) * 2015-02-05 2016-10-05 阿里巴巴集团控股有限公司 Message processing method and device
CN106603593A (en) * 2015-10-15 2017-04-26 北京京东尚科信息技术有限公司 HTTP calling method and device based on adaption
CN107634935A (en) * 2017-08-11 2018-01-26 北京大学深圳研究生院 A kind of content management-control method, device and the storage medium of NDN and IP UNEs

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8965952B1 (en) * 2009-09-22 2015-02-24 Cellco Partnership Processing service requests of multiple types on a common communication port for a service that accepts only one type
CN103064690A (en) * 2012-12-16 2013-04-24 互动在线(北京)科技有限公司 Development framework based on Android operating system and execution method thereof
CN103763394A (en) * 2014-02-10 2014-04-30 赛特斯信息科技股份有限公司 System and method for achieving access and callout of EJB through ESB
CN105991564A (en) * 2015-02-05 2016-10-05 阿里巴巴集团控股有限公司 Message processing method and device
CN106603593A (en) * 2015-10-15 2017-04-26 北京京东尚科信息技术有限公司 HTTP calling method and device based on adaption
CN107634935A (en) * 2017-08-11 2018-01-26 北京大学深圳研究生院 A kind of content management-control method, device and the storage medium of NDN and IP UNEs

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112822237A (en) * 2020-12-28 2021-05-18 北京奇艺世纪科技有限公司 Network request transmission method and device

Similar Documents

Publication Publication Date Title
WO2018214835A1 (en) Block chain service acceptance and consensus method and device
US20200099606A1 (en) Distrubuted testing service
US8819698B2 (en) Cross-platform web-based native device feature access
CN101202761B (en) System of distributed resource scheduling and method thereof
US11716264B2 (en) In situ triggered function as a service within a service mesh
US20130104135A1 (en) Data center operation
US7650609B2 (en) Multi-environment document management system access
US11232405B2 (en) Computer readable storage media for dynamic service deployment and methods and systems for utilizing same
EP3720094A1 (en) Information processing method, apparatus, device and system
CN102184227A (en) General crawler engine system used for WEB service and working method thereof
US20070011274A1 (en) Data transfer in a multi-environment document management system access
WO2014173151A1 (en) Method, device and terminal for data processing
CN109104368B (en) Connection request method, device, server and computer readable storage medium
CN115461735A (en) Media streaming with edge computation
US11848983B2 (en) Remotely discover and map a network resource model in a cloud environment
US20130159468A1 (en) Computer implemented method, computer system, electronic interface, mobile computing device and computer readable medium
US8200749B2 (en) Data processing method for generating service interface descriptions
CN111695072A (en) Method and device for converting HTTP (hyper text transport protocol) request
US20230283695A1 (en) Communication Protocol for Knative Eventing&#39;s Kafka components
EP3398304B1 (en) Network service requests
CN103002047A (en) RPC (Remote Procedure Call) type WEB SOA (Service-Oriented Architecture) method
CN114244912B (en) Data transmission method, device, computer equipment and storage medium
CN114827249A (en) Method and device for extending grid agent
KR20210128096A (en) Apparatus and method for interworking among internet of things platforms
CN104965909A (en) Dynamic web content request handling method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination