CN116361586B - Method for realizing HTTP protocol request data highlighting in webpage - Google Patents

Method for realizing HTTP protocol request data highlighting in webpage Download PDF

Info

Publication number
CN116361586B
CN116361586B CN202310649140.0A CN202310649140A CN116361586B CN 116361586 B CN116361586 B CN 116361586B CN 202310649140 A CN202310649140 A CN 202310649140A CN 116361586 B CN116361586 B CN 116361586B
Authority
CN
China
Prior art keywords
data
highlighting
state
content
request
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.)
Active
Application number
CN202310649140.0A
Other languages
Chinese (zh)
Other versions
CN116361586A (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.)
Chengdu No Sugar Information Tech Co ltd
Original Assignee
Chengdu No Sugar Information Tech 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 Chengdu No Sugar Information Tech Co ltd filed Critical Chengdu No Sugar Information Tech Co ltd
Priority to CN202310649140.0A priority Critical patent/CN116361586B/en
Publication of CN116361586A publication Critical patent/CN116361586A/en
Application granted granted Critical
Publication of CN116361586B publication Critical patent/CN116361586B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents
    • 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]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a method for realizing highlighting of HTTP protocol request data in a webpage, and relates to the technical field of Internet. The invention comprises the following steps: s1, converting request data into a character string array; s2, taking out one row of data from the character string array converted in the S1 for processing; s3, circularly executing S2 until the processing is finished; s4, returning an integer array after the S3 is completed, and carrying out highlighting processing after the S5 is obtained. The method and the device support setting of the data boundary marker to meet the function of marking the specific data of the request packet, realize the highlight display of the complex http request data packet, be applicable to all scenes which are based on the webpage development and need to highlight display the http request data packet, support the calling of the highlight method in a webworker mode, and improve the highlight performance.

Description

Method for realizing HTTP protocol request data highlighting in webpage
Technical Field
The invention belongs to the technical field of Internet, and particularly relates to a method for realizing highlighting of HTTP request data in a webpage.
Background
In analyzing and debugging software for HTTP protocol network requests, it is often necessary to highlight captured network request data, so that an analyst using such software can obtain better user experience and improve analysis efficiency. From development cost and cross-platform compatibility considerations, there is currently an increasing choice of client software to develop using browser-based frameworks (e.g., electronics, nw. Js, CEF, etc.), with no exception to web request analysis and debugging software.
Under the development architecture, the interface of the software is usually implemented by using a webpage development technology, and the presentation of the network request data is usually also based on a webpage code editor. In a conventional code editor scenario, highlighting of codes usually only needs to consider a single data highlighting rule, and the code editor usually has built-in highlighting special effects for various languages; the highlighting of the network request data needs to consider the compound data highlighting rule, and the code editor generally does not reasonably highlight the request packet which does not belong to the development language, for example, in one request packet, the header of the request packet and the packet body of the request packet respectively belong to different types of data, and two different highlighting rules need to be adopted.
Thus, current web code editors have difficulty highlighting complex request data, nor do some regular expression-based highlighting rule schemes generally have versatility, giving false highlighting on specific data packets.
Disclosure of Invention
The invention aims to solve the problems, and provides a method for realizing the highlighting of HTTP protocol request data in a webpage, which realizes the highlighting of complex HTTP request data packets in the webpage through javascript language, is applicable to all scenes which are required to highlight the HTTP request data packets based on webpage development, supports the calling of the highlighting method through a web worker mode, and can improve the highlighting performance.
In order to achieve the above purpose, the technical scheme adopted by the invention is as follows:
a method for implementing HTTP protocol request data highlighting within a web page, comprising the steps of:
s1, preprocessing incoming data, namely converting request data into a character string array;
s2, taking out one row of data from the character string array converted in the step S1, judging which state the current content is in by scanning each character in the current row of data, and recording the starting position and the state type of the content in the previous state if the previous state needs to be subjected to highlighting processing when the scanning process is switched from one state to the other state;
s3, executing the step S2 circularly until the processing is finished, obtaining all position and length information of the content needing to be highlighted, and representing the result by an integer array;
s4, after the step S3 is completed, returning an integer array, wherein each 5 numbers in the array are a group and represent a highlight content, and the 5 numbers respectively represent the relative line numbers of the highlight content in all the request data, the relative positions in the lines, the length of the highlight content, the highlight type and a reserved field;
s5, after the different editors acquire the array in the step S4, highlighting the content in the editors according to the position, the length and the type information of each highlighted content.
In the loop execution step S2, the processing of the request header and the processing of the request body are divided.
Further: in the analysis process of the request header, if the Content-Type header is encountered, recording the value corresponding to the Content-Type header, and extracting the Content-Type header provides a judging basis for selecting a process of FORM, MULTIPART, XML, JSON, HTML; if the Content-Type header contains the boundary=content, extracting the character string Content behind the boundary=as a composite Content boundary, wherein the boundary is used for providing basis for entering a highlighting analysis rule of the MULTIPART processing flow; if the request header is encountered to start with a blank or Tab, then the last request header state is considered not to end; other regular expression based methods have difficulty in handling this situation in order to properly parse the HTTP request header.
Further: in the process of executing step S2, if a blank line is encountered, including no content or only a custom "line feed," then the analysis flow is considered to enter into the process for the request body.
Further: in the processing of the request body, the selection of the corresponding value of the recorded header enters different processing states, so that different processing flows are entered, including FORM, MULTIPART, XML, JSON, HTML.
Further: when entering the FORM flow, defaulting to FORM state, encountering =, & gt, switching the data boundary symbols to FORM value, request parameter and data mark state respectively, and switching the rest to request parameter name state; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
Further: when entering the MULTIPART flow, defaulting to a composite content state, and enabling encountered-data boundary symbols to enter the composite content boundary state and the data marking state respectively; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
Further: when entering a JSON flow, defaulting to a JSON state, and entering a JSON array start state, a JSON object start state, a JSON character string start state and a data mark state respectively by [, {, ", and a data boundary symbol; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
Further: when entering XML and HTML flows, defaults are XML and HTML states respectively, and encountering < and data boundary symbols respectively enter an XML tag open state and a data mark state; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
Compared with the prior art, the invention has the following advantages:
1. the invention supports highlighting of HTTP packet headers: the method comprises the steps of highlighting the items such as a request method, a request path, a request parameter, a protocol version, a request header name, a value and the like; existing schemes often fail to refine highlighting or highlight by regular expressions, but are prone to errors.
2. The method supports highlighting Cookie sub-items in the header of the HTTP data packet; existing schemes typically fail to individually highlight key-value pairs of cookies within the request header.
3. The invention supports highlighting the condition that a plurality of lines exist in the value of the request head in the HTTP data packet head; existing schemes are generally unable to handle situations where there are multiple lines of data for the value of the request header.
4. The invention supports the highlighting of HTTP data packages of different types, supports the package formats of json, xml, html, composite content (multi part/form-data), forms (x-www-form-url) and the like; existing solutions often cannot simultaneously support highlighting of complex data packets of the aforementioned inclusion forms, especially for composite content.
5. The invention supports highlighting the boundary and parameters of the inclusion in the form of composite content; the prior proposal can not highlight the boundary of the inclusion of the composite content and the parameter sub-items in the inclusion.
6. The invention supports the use of specific highlighting rules for the bag body through the Content-Type in the request packet head; existing schemes typically cannot apply highlighting rules for a requestor based on a Content-Type request header.
7. The invention supports setting highlighting rules for each highlighting item of the data packet; existing schemes typically fail to highlight rule settings for each item of the request packet.
8. The invention supports calling in a web worker form so as to avoid blocking script execution in a webpage; existing highlighting schemes typically do not use a web worker scheme, and when the highlighting data is too large, there may be a situation where the page is blocked.
9. The invention supports the self-defined line feed character to meet the entity display of the line feed character in the request packet; existing highlighting schemes typically do not support highlighting and processing of custom line-boxes.
10. The invention supports setting the data boundary marker to meet the function of marking the specific data of the request packet; existing highlighting schemes typically do not support highlighting and processing of custom data boundary markers.
Drawings
Fig. 1 is a functional block diagram of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions in the embodiments of the present invention will be clearly and completely described below, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, based on the embodiments of the invention, which are apparent to those of ordinary skill in the art without inventive faculty, are intended to be within the scope of the invention. Accordingly, the detailed description of the embodiments of the invention provided below is not intended to limit the scope of the invention as claimed, but is merely representative of selected embodiments of the invention.
A method for realizing the highlighting of HTTP protocol request data in a webpage is shown in FIG. 1, and the specific processing process is as follows:
1. preprocessing the incoming data, and converting the request data into a character string array;
2. taking out one row of data from the array in the step 1 for processing, scanning each character in the current data to judge which state the current content is in, and recording the initial position and the state type of the content in the previous state if the previous state needs to be subjected to highlighting processing when the scanning process is switched from one state to the other state;
3. step 2 is circularly executed until the treatment is finished;
4. in the process of circularly executing the step 2, the method is mainly divided into the processing of the request head and the processing of the request body.
In the analysis process of the request header, if a Content-Type header is encountered, recording a value (CT) corresponding to the Content-Type header;
in the analysis process of the request header, if the Content-Type header contains the boundary=content, extracting the character string Content behind the boundary=as a composite Content boundary;
in the analysis process of the request header, if the request header is started by blank or Tab, the last request header state is considered not to be ended; by this sample embodiment, it is possible to form a highlight supporting the HTTP packet header: the method comprises the steps of highlighting the items such as a request method, a request path, a request parameter, a protocol version, a request header name, a value and the like; the technical problems that the existing scheme cannot be subjected to refined highlighting generally or is subjected to highlighting through a regular expression, but errors are easy to generate and the like are solved.
In the process of executing step 2, if a blank line is encountered, including no content or only a custom "line feed," then the analysis flow is considered to enter the process for the request body. The sample embodiment can realize supporting highlighting of Cookie sub-items in the header of the HTTP data packet; the technical problem that the key value pairs of Cookies in a request head cannot be subjected to independent highlighting in the existing scheme is solved.
In the process of processing the request body, selecting to enter different processing states through the CT value, so as to enter different processing flows, including FORM, MULTIPART, XML, JSON, HTML and the like; this sample embodiment may support highlighting different types of HTTP data packages, support for package formats in the form of json, xml, html, multi part/form-data, form (x-www-form-url coded), etc.; the technical problem that the existing scheme can not support the highlighting treatment of complex data packets in the form of the inclusion, especially for composite content, at the same time is solved.
In the specific embodiment, when entering the FORM flow in the processing process of the request body, the FORM state defaults, the =, & gt and the data boundary sign are respectively switched to the FORM value, the request parameter and the data marking state, and the other is switched to the request parameter name state; then, switching the subsequent states according to the step 2 and recording highlight data;
when entering the MULTIPART flow, defaulting to a composite content state, and enabling encountered-data boundary symbols to enter the composite content boundary state and the data marking state respectively; then, switching the subsequent states according to the step 2 and recording highlight data; the embodiment supports highlighting the boundary and parameters of the inclusion in the form of composite content; the technical problem that the boundary of a composite content bag body cannot be highlighted by the conventional scheme is solved. The embodiment supports setting a data boundary marker to meet the function of marking the specific data of the request packet; existing highlighting schemes typically do not support highlighting and processing of custom data boundary markers;
when entering a JSON flow, defaulting to a JSON state, and entering a JSON array start state, a JSON object start state, a JSON character string start state and a data mark state respectively by [, {, ", and a data boundary symbol; then, switching the subsequent states according to the step 2 and recording highlight data;
when entering XML and HTML flows, defaults are XML and HTML states respectively, and encountering < and data boundary symbols respectively enter an XML tag open state and a data mark state; and then performing subsequent state switching and recording highlight data according to the step 2.
After step 2 is completed, the embodiment returns an integer array, where every 5 digits in the array are a group, representing a highlight. The 5 numbers represent the relative number of rows, the relative position within a row, the length of the highlighted content, the type of highlighting and a reserved field, respectively, of the highlighted content in the total request data. And then after acquiring the array, the different editors highlight the content in the editors according to the information such as the position, the length, the type and the like of each highlight content. The embodiment supports highlighting the case that a plurality of lines exist in the value of the request head in the HTTP data packet head; the problem that the existing scheme cannot normally process the condition that a plurality of lines of data exist in the value of the request head is solved.
The embodiment supports the use of a specific highlighting rule for the inclusion by requesting the Content-Type in the inclusion; the problem that the existing scheme cannot apply the highlighting rule for the request body according to the Content-Type request header is solved.
Supporting to set a highlighting rule for each highlighting item of the data packet; the method solves the problem that the existing scheme cannot normally set highlight rules for various items of a request data packet.
Supporting calling in a web worker form to avoid blocking script execution in a web page; existing highlighting schemes typically do not use a web worker scheme, and when the highlighting data is too large, there may be a situation where the page is blocked.
Supporting a custom line feed character to meet the entity display of line feed symbols in a request packet; existing highlighting schemes typically do not support highlighting and processing of custom line-boxes.
The technical scheme of the invention realizes the highlight display of the complex http request data packet in the webpage through the javascript language, and is applicable to all scenes which are developed based on the webpage and need to highlight display the http request data packet, including client software developed based on the browser frame.
The highlighting method based on lexical analysis supports highlighting http request packets of different types (JSON, xml, html, composite content, forms), is more accurate than a request packet highlighting mode based on regular expressions, and can be expanded to types. The request parameters and cookies in the HTTP request packet and boundaries and parameters in the composite content are supported for highlighting. The highlighting of the custom line connector and the custom data boundary marker is supported, and the purposes of displaying the line connector and marking the data fragments in the request analysis scene are met. The method supports calling the highlighting method in a web worker mode, and the highlighting performance can be improved.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that the above-mentioned preferred embodiment should not be construed as limiting the invention, and the scope of the invention should be defined by the appended claims. It will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the spirit and scope of the invention, and such modifications and adaptations are intended to be comprehended within the scope of the invention.

Claims (9)

1. A method for implementing HTTP protocol request data highlighting in a web page, comprising the steps of:
s1, preprocessing incoming data, namely converting request data into a character string array;
s2, taking out one line of data from the character string array converted in the step S1 for processing, judging the state of the current content by scanning each character in the current line of data, and recording the starting position and the state type of the content of the previous state if the previous state needs to be subjected to highlighting processing when the scanning process is switched from one state to the other state;
s3, executing the step S2 circularly until all the position and length information of the content to be highlighted are obtained, and representing the result by an integer array;
s4, after the step S3 is completed, returning an integer array, wherein each 5 numbers in the array are a group and represent a highlight content, and the 5 numbers respectively represent the relative number of the highlight content in all the request data, the relative position in the row, the length of the highlight content, the highlight type and a reserved field;
s5, after the editor obtains the array in the step S4, highlighting the content in the editor according to the position, the length and the type information of each highlighted content.
2. The method for highlighting HTTP protocol request data in a web page according to claim 1, wherein the processing of the request header and the processing of the request body are divided in the loop execution step S2.
3. The method for highlighting HTTP protocol request data in a web page according to claim 2, wherein, during the analysis of the request header, if a Content-Type header is encountered, recording a value corresponding to the Content-Type header; extracting the character string Content behind the boundary=as a composite Content boundary if the Content-Type header contains the boundary=content; if a request header is encountered that starts with a blank or Tab, then the last request header state is considered not to end.
4. A method for highlighting HTTP protocol request data in a web page as recited in claim 3, wherein in performing step S2, if a blank line is encountered, including no content or only a custom, then the analysis flow is considered to enter a process for the requestor.
5. The method for highlighting HTTP protocol request data in a web page according to claim 2, wherein, in the processing of the request body, different processing states are entered by selecting the corresponding value of the header of the record, thereby entering different processing flows, wherein the processing flows include FORM, MULTIPART, XML, JSON, HTML.
6. The method for highlighting HTTP protocol request data in a web page according to claim 5, wherein when entering a FORM procedure, default to a FORM state, encountering =, and switching data delimiters to FORM values, request parameters, and data tag states, respectively, and switching others to request parameter name states; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
7. The method for implementing HTTP protocol request data highlighting in a web page as recited in claim 5, wherein when entering a multi art flow, defaulting to a composite content state, encountering-, data delimiters enter a composite content boundary state and a data tag state, respectively; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
8. The method for realizing the highlighting of HTTP protocol request data in a web page according to claim 5, wherein when entering a JSON flow, the default is a JSON state, and [, {, ", the data boundary symbol enter a JSON array start, a JSON object start, a JSON string start state and a data mark state respectively; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
9. The method for highlighting HTTP protocol request data in a web page according to claim 5, wherein when entering XML and HTML flows, default XML and HTML states, respectively, encounter < and data delimiters enter an XML tag open state and a data tag state, respectively; the subsequent state switching is then performed according to step S2 and the highlight data is recorded.
CN202310649140.0A 2023-06-02 2023-06-02 Method for realizing HTTP protocol request data highlighting in webpage Active CN116361586B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310649140.0A CN116361586B (en) 2023-06-02 2023-06-02 Method for realizing HTTP protocol request data highlighting in webpage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310649140.0A CN116361586B (en) 2023-06-02 2023-06-02 Method for realizing HTTP protocol request data highlighting in webpage

Publications (2)

Publication Number Publication Date
CN116361586A CN116361586A (en) 2023-06-30
CN116361586B true CN116361586B (en) 2023-10-03

Family

ID=86905530

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310649140.0A Active CN116361586B (en) 2023-06-02 2023-06-02 Method for realizing HTTP protocol request data highlighting in webpage

Country Status (1)

Country Link
CN (1) CN116361586B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106357482A (en) * 2016-11-30 2017-01-25 四川秘无痕信息安全技术有限责任公司 Method for implementing monitoring of webpage access based on network protocol
WO2020263676A1 (en) * 2019-06-24 2020-12-30 Oracle International Corporation Regular expression generation using span highlighting alignment
CN112783482A (en) * 2021-01-21 2021-05-11 深圳乐信软件技术有限公司 Visual form generation method, device, equipment and storage medium
CN114896417A (en) * 2022-05-20 2022-08-12 郑州轻工业大学 Method for constructing computer education knowledge graph based on knowledge graph

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11470143B2 (en) * 2020-01-23 2022-10-11 The Toronto-Dominion Bank Systems and methods for real-time transfer failure detection and notification

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106357482A (en) * 2016-11-30 2017-01-25 四川秘无痕信息安全技术有限责任公司 Method for implementing monitoring of webpage access based on network protocol
WO2020263676A1 (en) * 2019-06-24 2020-12-30 Oracle International Corporation Regular expression generation using span highlighting alignment
CN112783482A (en) * 2021-01-21 2021-05-11 深圳乐信软件技术有限公司 Visual form generation method, device, equipment and storage medium
CN114896417A (en) * 2022-05-20 2022-08-12 郑州轻工业大学 Method for constructing computer education knowledge graph based on knowledge graph

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"Moodle平台语法高亮功能的两种实现方法对比分析";赵亮 等;《河南科技》;第20-22页 *

Also Published As

Publication number Publication date
CN116361586A (en) 2023-06-30

Similar Documents

Publication Publication Date Title
US10887201B2 (en) Method for automatically monitoring end-to-end end user performance and apparatus for performing the method
CN108337236A (en) A kind of gRPC call methods and device based on Protobuf and HTTP/1.1
US20020046235A1 (en) Document creation and delivery
US20070016897A1 (en) Methods, apparatus and computer programs for optimized parsing and service invocation
CN109561104A (en) A kind of communication protocol conversion method and device
CN107015948B (en) Log information formatting method and system
CN113645224B (en) Network attack detection method, device, equipment and storage medium
US7353225B2 (en) Mechanism for comparing content in data structures
US11188443B2 (en) Method, apparatus and system for processing log data
CN111639275B (en) Routing information processing method, device, electronic equipment and computer storage medium
JP2008134906A (en) Business process definition generation method, device and program
CN116361586B (en) Method for realizing HTTP protocol request data highlighting in webpage
CN108664546B (en) XML data structure conversion method and device
CN116346961B (en) Financial message processing method and device, electronic equipment and storage medium
CN101261643A (en) Website page information statistical method and apparatus
CN109710808A (en) A kind of analytic method of XML file, system, device and readable storage medium storing program for executing
CN106648912A (en) Modular method and apparatus for data processing in data acquisition platform
JP2006065467A5 (en)
CN109657184B (en) Rich text processing method, rich text processing device, server and computer readable medium
CN112131374B (en) Text recognition method, device and server
CN112217896A (en) JSON message conversion method and related device
CN105306478A (en) System and method for normalization of HTTP (Hyper Text Transport Protocol) protocol data
CN111814161A (en) Data transmission method and system
CN110427541A (en) A kind of webpage content extracting method, system, electronic equipment and medium
CN112418335B (en) Model training method based on continuous image frame tracking annotation and electronic equipment

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
GR01 Patent grant
GR01 Patent grant