CN107154963B - Request processing method and device and electronic equipment - Google Patents

Request processing method and device and electronic equipment Download PDF

Info

Publication number
CN107154963B
CN107154963B CN201710210105.3A CN201710210105A CN107154963B CN 107154963 B CN107154963 B CN 107154963B CN 201710210105 A CN201710210105 A CN 201710210105A CN 107154963 B CN107154963 B CN 107154963B
Authority
CN
China
Prior art keywords
domain name
request
network request
failure
address
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
CN201710210105.3A
Other languages
Chinese (zh)
Other versions
CN107154963A (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.)
Beijing Cheetah Mobile Technology Co Ltd
Original Assignee
Beijing Cheetah Mobile Technology 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 Beijing Cheetah Mobile Technology Co Ltd filed Critical Beijing Cheetah Mobile Technology Co Ltd
Priority to CN201710210105.3A priority Critical patent/CN107154963B/en
Publication of CN107154963A publication Critical patent/CN107154963A/en
Application granted granted Critical
Publication of CN107154963B publication Critical patent/CN107154963B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • 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]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention discloses a request processing method, a request processing device and electronic equipment, wherein the method comprises the following steps: initiating a first network request using a web site including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length; when the first network request fails, determining the reason of the failure of the first network request; initiating a second network request according to the determined reason. By implementing the embodiment of the invention, the request success rate can be improved.

Description

Request processing method and device and electronic equipment
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a request processing method and apparatus, and an electronic device.
Background
Today, people can obtain various information such as pictures, texts, audio and video through the internet. Therefore, the internet greatly meets the needs of people in life. Generally, a user may enter a web address in a search bar of a browser or click a link on a web page to find and obtain a desired resource.
However, in practice, when the domain name resolution service is polluted, the same domain name is resolved into different Internet Protocol (IP) addresses, for example, an invalid IP address, so that the initiated network request returns a response message of request failure, and the request failure rate is high.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present invention is to provide a request processing method, a request processing device and an electronic device, which can reduce a failure rate of a network request.
In order to solve the foregoing technical problem, a first aspect of an embodiment of the present invention provides a request processing method, including:
initiating a first network request using a web site including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length;
when the first network request fails, determining the reason of the failure of the first network request;
initiating a second network request according to the determined reason.
Optionally, the determining a reason for the failure of the first network request includes:
determining whether a response message returned by the first network request comprises preset content;
and when the response message does not contain preset content, determining that the first network request failure is an Internet Protocol (IP) request failure.
Optionally, the initiating a second network request according to the determined reason includes:
determining a pre-stored IP address when the network request by using the first domain name is successful;
initiating a second network request using the web address including the IP address.
Optionally, the determining a reason for the failure of the first network request includes:
determining whether a response message returned by the first network request indicates that the domain name request fails;
and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
Optionally, the initiating a second network request according to the determined reason includes:
determining a standby domain name of the first domain name; and initiating a second network request by using the website comprising the standby domain name.
Optionally, the initiating a second network request using the website address including the IP address includes:
splicing the IP addresses into Uniform Resource Locators (URLs);
and initiating a second network request by using the spliced URL, wherein the header information in the second network request carries the IP address.
Optionally, the method further comprises:
acquiring at least one standby domain name of the first domain name provided by at least one domain name provider;
and storing a corresponding relation between the first domain name and the at least one standby domain name, wherein the corresponding relation also comprises a preset geographical range of each standby domain name.
Optionally, the determining the standby domain name of the first domain name includes:
determining a geographic location from which the first network request originated;
and inquiring the standby domain name corresponding to the geographic position.
A second aspect of the embodiments of the present invention provides a request processing apparatus, including:
a sending module, configured to initiate a first network request using a website including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length;
a determining module, configured to determine, when the first network request fails, a reason for the failure of the first network request;
the sending module is further configured to initiate a second network request according to the determined reason.
Optionally, the determining module. Specifically, the method is configured to determine whether a response message returned by the first network request includes preset content; and when the response message does not contain preset content, determining that the first network request failure is an Internet Protocol (IP) request failure.
Optionally, the sending module is specifically configured to determine a pre-stored IP address when the network request by using the first domain name is successful; initiating a second network request using the web address including the IP address.
Optionally, the determining module is specifically configured to determine whether a response message returned by the first network request indicates that the domain name request fails; and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
Optionally, the sending module is specifically configured to determine a standby domain name of the first domain name; and initiating a second network request by using the website comprising the standby domain name.
Optionally, the sending module initiates a second network request by using the website including the IP address, specifically: splicing the IP addresses into Uniform Resource Locators (URLs); and initiating a second network request by using the spliced URL, wherein the header information in the second network request carries the IP address.
Optionally, the apparatus further comprises:
an obtaining module, configured to obtain at least one standby domain name of the first domain name provided by at least one domain name provider;
and the storage module is used for storing the corresponding relation between the first domain name and the at least one standby domain name, and the corresponding relation also comprises a preset geographical range of each standby domain name.
Optionally, the sending module determines the standby domain name of the first domain name, specifically: determining a geographic location from which the first network request originated; and inquiring the standby domain name corresponding to the geographic position.
A third aspect of an embodiment of the present invention provides an electronic device, including: a processor, a memory, a communication interface, and a communication bus; the processor, the memory and the communication interface are connected through the communication bus and complete mutual communication; the memory stores executable program code; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory for executing a request processing method; wherein the method comprises the following steps:
initiating a first network request using a web site including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length;
when the first network request fails, determining the reason of the failure of the first network request;
initiating a second network request according to the determined reason.
A fourth aspect of the embodiments of the present invention provides a storage medium, where the storage medium is used to store an application program, and the application program is used to execute, when running, the request processing method according to the embodiments of the present invention.
A fifth aspect of the embodiments of the present invention provides an application program, where the application program is configured to execute, when running, a request processing method according to the embodiments of the present invention.
In the embodiment of the invention, the terminal can initiate the first network request by using the website comprising the first domain name, and when the first network request fails, the reason of the failure of the first network request is determined, so that the terminal can initiate the second network request according to the determined reason, and the efficiency of the success of the request is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart illustrating a request processing method according to a first embodiment of the present invention;
FIG. 2 is a flowchart illustrating a request processing method according to a second embodiment of the present invention;
fig. 3 is a flowchart illustrating a request processing method according to a third embodiment of the present invention;
FIG. 4 is a flowchart illustrating a request processing method according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a request processing apparatus according to a first embodiment of the present invention;
FIG. 6 is a diagram illustrating a structure of a request processing apparatus according to a second embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention.
Detailed Description
Currently, a terminal acquires a Uniform Resource Locator (URL) input by a user, and then submits the URL to a Domain Name System (DNS) server to resolve the URL. After the URL is successfully analyzed, the terminal initiates a hypertext Transfer Protocol (HTTP) request, and establishes a Transmission Control Protocol (TCP) connection between the terminal and the server using the HTTP request. Wherein, the server will return a response message to the terminal after monitoring the HTTP request. The DNS server may resolve the URL into a corresponding Internet Protocol (IP) address, so that the terminal may access the corresponding web server using the IP address.
However, in practice, it has been found that domain name resolution fails due to geographical location limitations. For example, domain name a provided by a domain name provider is valid in region 1 but invalid in region 2, so that when a terminal initiates a network request using the domain name a in region 2, the network request fails. In addition, when the DNS server is maliciously attacked or the DNS server cache is polluted, even if the domain name resolution is successful, the domain name is resolved to an invalid or wrong IP address because the DNS server caches a wrong IP address for the domain name, that is, the network request fails.
In order to solve the above problem, embodiments of the present invention provide a request processing method, an apparatus, and a terminal, which can improve a success rate of a network request.
Referring to fig. 1, fig. 1 is a flowchart illustrating a request processing method according to a first embodiment of the present invention. The request processing method can be applied to various intelligent terminals including but not limited to tablet computers, smart phones, intelligent wearable devices and the like. And the terminal may comprise a client implementing the method. The client may be a browser, such as an IE browser, google browser, etc. As shown in fig. 1, the request processing method may include:
s101, the terminal initiates a first network request by using the website including the first domain name.
In the embodiment of the invention, the first domain name is a domain name stored when the network request is successful within a preset time length. In other words, the first domain name may be a default domain name or a standby domain name that is stored when the network request is successful within a preset time period. Wherein the preset duration includes, but is not limited to, the time required from the initiation of the first network request to the receipt of the response message regarding the first network request. Optionally, the preset time duration may also be a time duration negotiated by both communication parties.
Optionally, the first domain name may also be a domain name saved when the network request is successful. In other words, the first domain name may be a default domain name or a backup domain name, etc. that is saved when the network request is successful.
It should be noted that the process of initiating the first network request by using the website including the first domain name in step S101 may include acquiring the website including the first domain name from the terminal, and sending the HTTP request including the first domain name to the corresponding server.
In this embodiment of the present invention, the value of the host name host in the request header of the HTTP request including the first domain name is the first domain name. Optionally, the first network request may be an HTTP request including the first domain name.
Further optionally, when the first network request is an HTTP request including the first domain name, the process of initiating the first network request using the website including the first domain name in step S101 may be understood as that the terminal sends the HTTP request including the first domain name to the corresponding server using the website including the first domain name.
For example, if the first network request is an HTTP request including the first domain name, the terminal can send the HTTP request including the first domain name www.abc.com using the website HTTP:// www.abc.com/request. The value of the host name host in the request header of the HTTP request is the first domain name www.abc.com.
S102, when the first network request fails, determining the reason of the first network request failure.
In this embodiment of the present invention, the reason for the failure of the first network request at least includes: IP request failure, domain name request failure.
It should be noted that, after receiving the first network request, the server may return a corresponding response message to the terminal according to the first network request. The terminal may determine that the first network request failure is an IP request failure or a domain name request failure according to the returned response message.
Optionally, the determining, by the terminal, that the first network request failure is an IP request failure may include: determining whether a response message returned according to the first network request includes preset content; and if the response message does not contain the preset content, determining that the first network request failure is an IP request failure. The preset content may be protocol agreement information including specified content negotiated between both communication parties, that is, the client and the server, and the protocol agreement information is established on the basis of the HTTP protocol.
For example, if the preset content is that the returned response message includes the specific character string information, but after the client sends the first network request by using the website including the first domain name, the response message returned by the server does not include the specific character string information, then the terminal may determine that the first network request failure is an IP request failure.
Optionally, the determining, by the terminal, whether the first network request failure is a domain name request failure may include: determining whether a response message returned by the first network request indicates that the domain name request fails; and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
It should be noted that, the determining whether the response message returned by the first network request indicates that the domain name request fails may include: in the process of initiating the domain name resolution in the first network request, if the response message received by the terminal is an error code fed back by the server during the domain name resolution, it may be determined that the response message indicates that the domain name request fails.
For example, if the response message received by the terminal is an error code such as the error code 105 or the error code 137 during the domain name resolution process in the first network request, it may be determined that the response message indicates that the domain name request fails, that is, the first network request fails. Wherein the error code 105 indicates the domain name resolution error; an error code 137 indicating that the domain name cannot be resolved.
It should be noted that, the determining whether the response message returned by the first network request indicates that the domain name request fails may further include: after the domain name resolution is successful, the terminal can judge whether the domain name request fails according to the status line information in the response message. If it is determined that the domain name request fails according to the status line information, it may be determined that the response message indicates that the domain name request fails. If it is determined that the domain name request is successful according to the status line information, it may be determined that the response message does not indicate that the domain name request failed.
For example, if the status line information of the response information returned according to the first network request is 404NOT FOUND, which can be understood as a domain name request failure, it may be determined that the response information indicates a domain name request failure, and thus it may be determined that the first network request failure is a domain name request failure.
Generally, if the status line information of the returned response information is 200OK, it represents that the domain name request is successful, that is, it can be understood that the response information does not indicate that the domain name request has failed. It may thus be determined that the first network request failure is not a domain name request failure.
In some embodiments, if the domain name resolution is successful, but the status line information of the response message returned by the server is NOT 200OK, is 404NOT FOUND, or other status line information, and may also be understood as an IP request failure, it may be determined that the response message indicates an IP request failure, and thus it may be determined that the first network request failure is an IP request failure.
S103, initiating a second network request according to the determined reason.
It should be noted that, through step S102, it can be determined that the specific reason causing the failure of the first network request is that the IP request fails or the domain name request fails.
Optionally, when it is determined that the first network request failure is an IP request failure, the terminal may determine a pre-stored IP address when the network request using the first domain name is successful, and may initiate a second network request using a website including the IP address.
It should be noted that the terminal may determine, by looking up the mapping relationship of the local cache, the pre-stored IP address corresponding to the successful network request by using the first domain name. The mapping relationship may be a correspondence relationship between each domain name and a corresponding IP address, which is stored when the terminal successfully requests the network address including each domain name.
For example, if the terminal fails to send the first network request using the http:// www.abc.com/request, it is queried whether the mapping relationship between the first domain name www.abc.com and the IP address exists in the local cache. So as to determine the pre-stored corresponding IP address when the network request by using the first domain name is successful. If the mapping relation between the domain name www.abc.com and the IP address 1.2.3.4 is cached in the terminal. The terminal determines that the IP address corresponding to the first domain name is 1.2.3.4.
It should be noted that, when the terminal initiates the second network request by using the website including the IP address, the terminal may splice the website including the first domain name by using the IP address to initiate the second network request by using the website including the IP address.
It should be noted that the above process of initiating the first network request by using the website address including the IP address may include acquiring the website address including the IP address from the terminal, and sending an HTTP request including the IP address to the corresponding server.
In the embodiment of the present invention, the value of the host name host in the request header of the HTTP request including the IP address is the IP address. Alternatively, the second network request may be an HTTP request including the IP address.
It should be noted that, when the first network request is an HTTP request including the IP address, the above process of initiating the first network request using the website containing the IP address may be understood as that the terminal sends the HTTP request including the IP address to the corresponding server using the website including the IP address.
For example, when the second network request is an HTTP request including the IP address 1.2.3.4, the terminal may send the HTTP request including the IP address 1.2.3.4 to the corresponding server using HTTP:// 1.2.3.4/request. Wherein, the value of host in the request header of the HTTP request including the IP address is 1.2.3.4.
Optionally, when determining that the first network request fails because the domain name request fails, the terminal may determine a standby domain name of the first domain name; a second network request is initiated with the web address including the alternate domain name.
Further optionally, the determining the standby domain name of the first domain name may include: the terminal may determine the standby domain name corresponding to the first domain name by looking up the correspondence of the local cache. Wherein each domain name in the correspondence corresponds to at least one standby domain name.
Further optionally, the determining the standby domain name of the first domain name may further include: determining a geographic location from which the first network request originated; and inquiring the standby domain name corresponding to the geographic position.
Optionally, the terminal may determine the preset geographic range corresponding to the geographic location by querying the corresponding relationship, so as to obtain the standby domain name corresponding to the preset geographic classification. In the corresponding relationship, each domain name corresponds to at least one standby domain name, and the corresponding relationship may further include a preset geographical range of each standby domain name.
It should be noted that the above process of initiating the second network request by using the website including the standby domain name may include obtaining the website including the standby domain name from the terminal, and sending an HTTP request including the standby domain name to the corresponding server.
In the embodiment of the present invention, the value of the host name host in the request header of the HTTP request including the standby domain name is the standby domain name. Alternatively, the second network request may be an HTTP request including the alternate domain name.
Further optionally, when the second network request is an HTTP request including a standby domain name, the above process of initiating the second network request using the website including the standby domain name may be understood as that the terminal sends the HTTP request including the standby domain name to the corresponding server using the website including the standby domain name.
For example, when the second network request is an HTTP request including the standby domain name www.abc2.com, the terminal may send the HTTP request including the standby domain name www.abc2.com to the corresponding server using HTTP:// www.abc2.com/request. Wherein, the value of host in the request header of the HTTP request including the standby domain name is www.abc2.com.
As can be seen, in the embodiment shown in fig. 1, the terminal may initiate a first network request by using a website including a first domain name, and when the first network request fails, determine a reason for the failure of the first network request; and initiating a second network request according to the determined reason so as to improve the efficiency of successful request.
Referring to fig. 2, fig. 2 is a flowchart illustrating a request processing method according to a second embodiment of the present invention. The request processing method can be applied to various terminals, the terminals can be various intelligent terminals including but not limited to tablet computers, mobile phones, intelligent wearable devices and other terminals, and clients implementing the method can be installed in the terminals. The client may include a browser, such as an IE browser, google browser, or the like. As shown in fig. 2, the request processing method may include the steps of:
s201, the terminal initiates a first network request by using the website including the first domain name.
In the embodiment of the invention, the first domain name is a domain name stored when the network request is successful within a preset time length. The network request success means that the terminal can request network resources from a corresponding network server through the first domain name.
For example, if the first domain name is www.abc.com, the web address including the first domain name may be http:// www.abc.com, and the first network request initiated using the network including the first domain name may be http:// www.abc.com/request.
In this embodiment of the present invention, the value of the host name host in the request header of the HTTP request including the first domain name is the first domain name. Optionally, the first network request may be an HTTP request including the first domain name.
S202, when the first network request fails, the terminal determines a pre-stored corresponding Internet Protocol (IP) address when the network request by using the first domain name succeeds.
In the embodiment of the present invention, the first domain name may be stored when the network request is successful by using the first domain name within the effective duration. In other words, the first domain name may be a default domain name or a standby domain name that is stored when the network request is successful.
It should be noted that, after the terminal initiates the first network request to the server through step S201, the server may return a corresponding response message after receiving the first network request, so as to respond to the first network request. The terminal may determine whether the first network request was successful based on the response message. For example, if the returned response information includes the status line information of 200OK and the specific character string information, it may be determined that the first network request is successful.
In step S202, if the terminal determines that the first network request fails according to the response message returned by the server, the terminal may determine, through the mapping relationship, the IP address corresponding to the first domain name that is pre-stored when the network request succeeds, so as to execute step S203 to initiate the second network request using the website including the IP address. The mapping relation is the corresponding relation between each domain name and the corresponding IP address when the terminal uses the website including each domain name to carry out the network request successfully.
For example, if the terminal fails to send the first network request using the http:// www.abc.com/request, it is queried whether the mapping relationship between the first domain name www.abc.com and the IP address exists in the local cache. So as to determine the pre-stored corresponding IP address when the network request by using the first domain name is successful. If the mapping relation between the domain name www.abc.com and the IP address 1.2.3.4 is cached in the client. The client determines that the IP address corresponding to the first domain name is 1.2.3.4.
S203, the terminal initiates a second network request by using the website including the IP address.
It should be noted that the process of initiating the second network request by using the web address including the IP address in step S203 may include acquiring the web address including the IP address from the terminal, and sending an HTTP request including the IP address to the corresponding server.
In this embodiment of the present invention, the value of the host in the request header of the HTTP request including the IP address may be the IP address. Alternatively, the second network request may be an HTTP request including the IP address.
Alternatively, when the second network request is an HTTP request including an IP address, the process of initiating the second network request using the website including the IP address in step S203 may be understood as that the terminal may send the HTTP request including the IP address to the corresponding server using the website including the IP address.
It should be noted that, when initiating the second network request by using the web address including the IP address, the terminal may use the IP address to splice the web address including the first domain name, so as to initiate the second network request by using the web address including the IP address.
For example, when the terminal fails to make the first network request with the website http:// www.abc.com/request, the terminal may determine that the IP address saved when the network request is successful with the domain name www.abc.com is 1.2.3.4 in step S202. After determining the IP address, the terminal may use the IP address to splice the first domain name in the web address where http:// www.abc.com/request is modified to http://1.2.3.4/request to send a second network request using the web address.
As can be seen, as shown in fig. 2, the terminal may initiate a first network request using a web address including a first domain name; when the first network request fails, the pre-stored IP address corresponding to the successful network request by using the first domain name can be determined; the second network request is initiated by utilizing the website including the IP address, so that the condition that the IP address is failed to be always analyzed by the conventional cache mechanism or the domain name initiating the network request is analyzed to the wrong or invalid IP address within a period of time can be effectively avoided, and the efficiency and the reliability of the request are improved.
Fig. 3 is a flowchart illustrating a request processing method according to a third embodiment of the present invention. In particular, the request processing method may be applied to various terminals, the terminals may be various smart terminals including but not limited to tablet computers, mobile phones, smart wearable devices and the like, and the terminals may include clients implementing the method. The client may be a browser, such as an IE browser, google browser, etc. Specifically, the method may comprise the steps of:
s301, the terminal initiates a first network request by using the website including the first domain name.
It should be noted that the terminal may initiate the first network request by using the website including the first domain name. After the server receives the network request, a response message may be returned to the terminal. The terminal may determine whether the first network request failed based on the response message.
Optionally, when the first network request fails, the terminal may perform the step S302 of determining whether the first network request failure is an IP request failure according to the response message, and may sequentially perform the steps S303 and S304.
Further optionally, when the first network request fails, the terminal may further perform the step S305 of determining whether the first network request failure is a domain name request failure according to the response message, and may sequentially perform the steps S306 and S307.
In the embodiment of the present invention, step S302 and step S305 are executed in parallel, that is, the terminal may execute the step of determining whether the first network request failure is an IP request failure and the step of determining whether the first network request failure is a domain name request failure at the same time.
Alternatively, the terminal may first determine whether the first network request failure is an IP request failure, and further determine whether the first network request failure is a domain name request failure after determining that the first network request failure is not an IP request failure. Further optionally, the terminal may first determine whether the first network request failure is a domain name request failure, and after determining that the first network request failure is not a domain name request failure, further determine whether the first network request failure is an IP request failure.
S302, when the first network request fails, the terminal determines whether the first network request fails to be an IP request failure. If the IP request fails, step S303 is executed.
It should be noted that, in step S301, the terminal may initiate the first network request by using the website including the first domain name, and may execute step S302 when the first network request fails, so as to determine whether the first request failure is an IP request failure. When it is determined that the first network request failure is an IP request failure, step S303 is executed to determine an IP address corresponding to the first domain name when the request is successful, and send a second network request by using the website including the IP address.
Further, the determining whether the first network request failure is an IP request failure in step S302 may include: the terminal determines whether a response message returned by the first network request includes preset content; when the response message does not include the preset content, it may be determined that the first network request failure is an IP request failure. The preset content may be protocol agreement information including specified content negotiated between both communication parties, that is, the client and the server, and the protocol agreement information is established on the basis of the HTTP protocol.
For example, if the preset content is that the returned response message includes the specific character string information, but after the client sends the first network request by using the website including the first domain name, the response message returned by the server does not include the specific character string information, then the terminal may determine that the first network request failure is an IP request failure.
S303, when the first network request failure is determined to be an IP request failure, the terminal determines a pre-stored IP address corresponding to the successful network request by using the first domain name;
s304, the terminal initiates a second network request by using the website including the IP address.
It should be noted that, in step S303, when determining that the first network request failure is an IP request failure, the terminal may determine, by looking up a mapping relationship of the local cache, an IP address corresponding to a network request success performed by using the first domain name, which is stored in advance.
In the embodiment of the present invention, the mapping relationship may be a correspondence relationship between each domain name and a corresponding IP address, which is stored when the terminal successfully requests the network using the website including each domain name. Please refer to table 1, which is a mapping relationship table between a domain name and a corresponding IP address stored in a terminal when a network request is successful according to an embodiment of the present invention. For example, if the terminal uses the website including the domain name a to make a network request to the server where the IP address 1 is located, the domain name a and the corresponding IP address 1 are cached locally.
TABLE 1
Domain name IP address
Domain name A IP address 1
Domain name B IP address 2
For example, if the URL acquired by the terminal is http:// domain name A, when the terminal determines that the first network request failure is the IP request failure according to the response message returned by the server, the terminal queries a local mapping relationship, such as table 1, so as to determine that the corresponding IP address is IP address 1 when the network request using the domain name A is successfully stored in advance.
It should be noted that, in step S304, when the terminal initiates the second network request by using the website address including the IP address, the terminal may splice the website address including the first domain name by using the IP address to initiate the second network request by using the website address including the IP address. Alternatively, the second network request may be an HTTP request including the IP address.
S305, when the first network request fails, the terminal determines whether the first network request fails to be a domain name request failure.
It should be noted that, after the terminal performs step S302, if it is determined that the first network request fails according to the response message returned by the server, in step S305, the terminal may further determine whether the first network request failure is a domain name request failure.
It should be noted that, the determining whether the response message returned by the first network request indicates that the domain name request fails may include: in the process of initiating the domain name resolution in the first network request, if the response message received by the terminal is an error code fed back by the server during the domain name resolution, it may be determined that the response message indicates that the domain name request fails. .
For example, if the response information returned by the server indicates that the domain name resolution is wrong, the response information is the error code 105, which indicates that the domain name request fails this time.
It should be noted that, the determining whether the response message returned by the first network request indicates that the domain name request fails may further include: the terminal can judge whether the domain name request fails according to the status line information in the response message returned by the server. If it is determined that the domain name request fails according to the status line information, it may be determined that the response message indicates that the domain name request fails. If it is determined that the domain name request is successful according to the status line information, it may be determined that the response message does not indicate that the domain name request failed.
It should be noted that, the determining whether the response message returned by the first network request indicates that the domain name request fails may further include: after the domain name resolution is successful, the terminal can judge whether the domain name request fails according to the status line information in the response message. If it is determined that the domain name request fails according to the status line information, it may be determined that the response message indicates that the domain name request fails. If it is determined that the domain name request is successful according to the status line information, it may be determined that the response message does not indicate that the domain name request failed.
For example, if the status line information of the response information returned by the server is 404NOT FOUND, it represents that the resource requested by the terminal does NOT exist, and it can be understood that the domain name request has failed.
Generally, if the status line information of the returned response information is 200OK, it represents that the domain name request is successful, that is, it can be understood that the response information does not indicate that the domain name request has failed. It may thus be determined that the first network request failure is not a domain name request failure.
In some embodiments, if the domain name resolution is successful, but the status line information of the response message returned by the server is NOT 200OK, is 404NOT FOUND, or other status line information, and may also be understood as an IP request failure, it may be determined that the response message indicates an IP request failure, and thus it may be determined that the first network request failure is an IP request failure.
In some embodiments, if the domain name resolution is successful, but the status line information of the response information returned by the server is not 200OK, it may also be defined as an IP request failure.
S306, when the first network request failure is determined to be a domain name request failure, the terminal determines a standby domain name of the first domain name.
It should be noted that, the determining the standby domain name of the first domain name in step S306 may include: determining a geographic location from which the first network request originated; and inquiring the standby domain name corresponding to the geographic position.
Alternatively, the terminal may determine the backup domain name corresponding to the geographic location by clarifying the locally stored correspondence. In the corresponding relationship, each domain name corresponds to at least one standby domain name, and the corresponding relationship further includes a preset geographical range of each standby domain name. Wherein the predetermined geographic range may include one or more regions where network requests can be sent using the alternate domain name.
Further optionally, in step S306, when it is determined that the first network request fails and is a domain name failure, the terminal may determine a geographic location where the first network request is initiated, and may further determine a preset geographic range to which the geographic location belongs, so as to search for a standby domain name corresponding to the preset geographic range in the correspondence relationship, so that the terminal may perform the initiating of the second network request in step S307.
For example, the terminal initiates the first network request at the location 1 by using the website including the domain name a, and if it is determined that the first network request fails to be the domain name failure according to the response message of the server, the terminal determines that the geographic location initiating the first network request is the location 1, and determines the preset geographic range to which the geographic location belongs. Further, after determining that the location 1 belongs to the region 1, the terminal may determine the spare domain name matched with the domain name in the region 1 by querying a corresponding correspondence table, such as table 2. From table 2, it can be determined that the standby domain name corresponding to zone 1 is domain name a1, and the terminal can send the second network request using the website including domain name a 1. Please refer to table 2, which is a table of correspondence between domain names, standby domain names, and preset geographic ranges according to an embodiment of the present invention:
TABLE 2
Figure BDA0001260788540000101
Optionally, if the standby domain name corresponding to the first domain name is not queried in the local cache, at least one standby domain name corresponding to the first domain name, which is provided by at least one domain name provider, is obtained. And storing the corresponding relationship between the first domain name and the standby domain name in a local cache, and storing the preset geographic range of each standby domain name in the corresponding relationship, so that when the domain name request is failed by reusing the first domain name, the standby domain name recorded in the preset geographic range in the corresponding relationship can be directly utilized to initiate a network request again.
S307, initiating a second network request by using the website including the standby domain name.
It should be noted that the process of initiating the second network request by using the website including the standby domain name in step S307 may include acquiring the website including the standby domain name from the terminal, and sending an HTTP request including the standby domain name to the corresponding server.
In the embodiment of the present invention, the value of the host name host in the request header of the HTTP request including the standby domain name is the standby domain name. Alternatively, the second network request may be an HTTP request including the alternate domain name.
Further optionally, when the second network request is an HTTP request including a standby domain name, the process of initiating the second network request by using the website including the standby domain name in step S207 may be understood as that the terminal sends the HTTP request including the standby domain name to the corresponding server by using the website including the standby domain name.
For example, if the backup domain name of domain name B is domain name B1, when the second network request is an HTTP request including domain name B1, the terminal can send the HTTP request including domain name B1 to the corresponding server using the website HTTP:// domain name B1. Wherein, the value of host in the request header of the HTTP request including the standby domain name is domain name B1.
It should be noted that, when initiating the second network request by using the website including the above-mentioned standby domain name, the terminal may use the standby domain name to splice the website including the first domain name, so as to initiate the second network request by using the website including the standby domain name.
For example, if the website acquired by the terminal is http:// domain name B, after the terminal fails to make a first network request in region 3 using the website, the terminal determines the geographical location initiating the first network request, and if the geographical location is determined to belong to region 3, and it is determined that the domain name has a corresponding standby domain name in region 3 by looking up the corresponding relationship in table 2, such as domain name B1, the terminal may use the domain name B1 to splice the website where the domain name B is located, that is, the website is changed from http:// domain name B to http:// domain name B1 to initiate a second network request.
As can be seen, in the embodiment shown in fig. 3, when the network request fails, the terminal may determine whether the network request failure is an IP request failure by determining whether the received response information includes preset content, and if the network request failure is an IP request failure, obtain an IP address used by the domain name when the network request succeeds, so as to send the second network request more quickly and effectively. In addition, after determining that the first network request fails, if it is determined that the request failure is a domain name request failure, the terminal may initiate a second network request using the standby domain name after determining the standby domain name corresponding to the first domain name. By implementing the embodiment of the invention, the terminal can select to use the standby domain name or the IP address when the request is successful to send the network request again by combining the specific condition that the first network request fails, thereby improving the request success rate.
Fig. 4 is a flowchart illustrating a request processing method according to a fourth embodiment of the present invention. In particular, the method can be applied to various terminals, the terminals can be various intelligent terminals including but not limited to tablet computers, mobile phones, intelligent wearable devices and the like, and the terminals can include clients for implementing the method. Specifically, the method may comprise the steps of:
s401, whether the terminal stores the domain name when the network request is successful or not is judged; if the data is saved, executing step S402, if the data is not saved, executing step S403;
s402, the terminal acquires the domain name when the network request is successful;
s403, the terminal acquires a default domain name;
s404, the terminal sends a network request by using the website including the first domain name.
In step S401, if the terminal determines that the domain name when the network request is successful is stored, the terminal may sequentially execute step S402 and step S404. That is, after determining that the domain name when the network request is successful is stored, the terminal may obtain the domain name when the network request is successful, and send the network request using the domain name including the domain name when the network request is successful. The network request here may be the first network request mentioned in the foregoing embodiments.
It should be noted that the above-mentioned process of sending a network request using a website including a domain name when the network request is successful may correspond to the process of sending a network request using a website including a first domain name in the foregoing embodiment.
In step S401, if it is determined that the terminal does not store the domain name when the network request is successful, the terminal may sequentially execute step S403 and step S404. That is, after determining that the domain name when the network request is not successfully stored, the terminal may obtain the default domain name, and send the network request using the website including the default domain name. The network request here may be the first network request mentioned in the foregoing embodiments.
It should be noted that the above-mentioned process of sending a network request using a website including a default domain name may correspond to the process of sending a network request using a website including a first domain name in the foregoing embodiments.
S405, whether the domain name request is successful. If the failure occurs, go to step S406. If successful, go to step S408.
It should be noted that, after the terminal sends the network request, the server may return a response message to the client. The terminal can judge whether the domain name request in the network request is successful according to the response message returned by the server. If the domain name request fails, it may be determined that the network request fails, then step S406 is performed to determine whether the corresponding standby domain name is cached in the terminal. If the IP request is successful, step S408 is executed to determine whether the returned response message includes preset content, so as to determine whether the IP request is successful.
The domain name request failure may include: in the process of initiating the domain name resolution in the first network request, if the response message received by the terminal is an error code fed back by the server in the process of domain name resolution, it can be determined that the domain name request fails.
For example, if the response information returned by the server indicates that the domain name resolution is wrong, the response information is the error code 105, which indicates that the domain name request fails this time.
It should be noted that, the determining whether the response message returned by the first network request indicates that the domain name request fails may further include: if the domain name resolution is successful, the terminal can judge whether the domain name request fails according to the state line information in the response message returned by the server. If it is determined that the domain name request fails according to the status line information, it may be determined that the response message indicates that the domain name request fails. If it is determined that the domain name request is successful according to the status line information, it may be determined that the response message does not indicate that the domain name request failed.
For example, if the response message returned by the server includes the status line information of 200OK, it indicates that the domain name request is successful. If the response information returned by the server contains the status line information of 404NOT FOUND, it indicates that the domain name request fails.
In some embodiments, if the domain name resolution is successful, but the status line information of the response information returned by the server is not 200OK, it may also be defined as an IP request failure.
S406, the terminal determines whether the standby domain name exists. If yes, go to step S407. If not, the flow is ended.
S407, the terminal acquires the standby domain name, and executes step S404.
It should be noted that, in step S406, when determining that the domain name request fails, the terminal may obtain the geographic location where the network request is initiated, and query the standby domain name corresponding to the current geographic location. In step S407, the terminal may acquire the standby domain name so as to initiate a network request again with the web address including the standby domain name in step S404.
Optionally, when a domain name corresponds to one or more standby domain names, the terminal may find, according to the geographical position, a standby domain name that can be used by the domain name within a preset geographical range to which the geographical position belongs in the correspondence relationship after determining the geographical position at which the network request is initiated, so as to initiate the network request again by using the standby domain name, thereby improving the request success rate. Each domain name in the correspondence corresponds to at least one standby domain name, and each standby domain name may correspond to at least one preset geographical range.
It should be noted that the above-mentioned process of initiating a network request again using a website including the standby domain name may correspond to the process of initiating a second network request using a website including the standby domain name in the foregoing embodiment, and the process may include acquiring a website including the standby domain name from the terminal, and sending an HTTP request including the standby domain name to the corresponding server.
Alternatively, when a network request is initiated again using a website containing the standby domain name, the terminal may concatenate the URL including the default domain name or the URL of the last successful domain name with the standby domain name. And when the HTTP request containing the standby domain name is sent, the value of the host of the request head of the HTTP request is the standby domain name.
For example, if the backup domain name of the domain name a is determined to be a1 through the correspondence relationship, after the terminal concatenates http:// domain name a using a1, the URL becomes http:// domain name a1, and the terminal can send the network request again using http:// domain name a 1. When an HTTP request including a standby domain name is sent, a host of a request header of the HTTP request takes a value of domain name a 1.
S408, the terminal determines whether preset content is contained. If yes, go to step S413. If not, go to step S409.
It should be noted that, if it is determined through step S405 that the domain name request is successful. The terminal may further determine whether the response message returned by the server contains preset content for determining whether the IP request is successful. If so, it may be determined that the IP request is successful, and the network request is successful this time, and the terminal sequentially performs step S413 and step S414. If not, step S409 is executed, and it is determined whether the IP address of the last success is cached in the terminal, so as to send the network request again. The IP address refers to an IP address corresponding to the domain name when the network request is successful last time.
S409, whether the terminal stores the IP address when the network request is successful or not is judged; if yes, go to step S410. If not, go to step S406;
s410, the terminal acquires the IP address;
s411, the terminal initiates a network request.
It should be noted that, if the terminal determines that the IP address when the network request is successfully cached locally, the terminal may use the IP address to splice the URL including the default domain name or the URL of the domain name when the network request is successfully made, so as to initiate the network request using the website including the IP address. Accordingly, the network request herein may be the second network request mentioned in the foregoing embodiments.
It should be noted that the above process of initiating a network request by using a web address including an IP address may correspond to the process of initiating a second network request by using a web address including an IP address in the foregoing embodiments, wherein the process may include acquiring a web address including the IP address from a terminal, and sending an HTTP request including the IP address to a corresponding server.
In this embodiment of the present invention, the value of the host in the request header of the HTTP request including the IP address is the IP address. Alternatively, the network request here may be an HTTP request including the IP address.
Alternatively, when the second network request is an HTTP request including an IP address, the above procedure of initiating a network request using a web address including an IP address may be understood as that the terminal may send the HTTP request including an IP address to a corresponding server using a web address including an IP address.
For example, when the network request is an HTTP request including an IP address 1.2.3.4, the terminal may send the HTTP request including the IP address 1.2.3.4 to the corresponding server using HTTP:// 1.2.3.4/request. Wherein, the value of host in the request header of the HTTP request including the IP address is 1.2.3.4.
Alternatively, in step S409, if it is determined that the last successful IP address is not included, step S406 may be executed to further determine whether the domain name has an unused standby domain name, and if the standby domain name is included, the standby domain name may be used to send the network request of the website including the standby domain name again, so as to increase the success rate of the network request.
In practical applications, if a news client wants to obtain some real-time news, the news client can start a program to refresh the news after the terminals are networked. If the DNS pollution occurs at this time, the page requested by the news client is resolved to an invalid server instead of the original news server, and the server cannot return the preset content, which may be the news content that the user wants to browse. By the method provided by the embodiment of the invention, the client can try to use the IP address used when the last request is successful. After the client successfully requests the news page by using the network including the IP address, the refreshed news page can be normally displayed.
S412, whether the network request is successful or not; if not, go to step S406. If successful, the process is ended.
It should be noted that, after the terminal initiates the network request by using the website including the IP address, the terminal may determine whether the network request is successful according to the response message returned by the server. In case that the network request transmitted using the website including the IP address fails, the terminal may perform step S406 to attempt to initiate a network request again using the website including the alternate domain name.
In the embodiment of the present invention, the network request is successful because the domain name request is successful and the IP request is successful. The network request failure is an IP request failure and/or a domain name request failure. Wherein, the failure of the IP request can be determined according to whether the returned response message contains preset content; the failure of the domain name request can be determined according to the status line information in the returned response message, for example, whether the returned status line information is 200 OK.
S413, storing the domain name;
and S414, storing the mapping relation between the domain name and the IP address.
It should be noted that, in step S408, the terminal may determine that the response message returned by the server includes the preset content. After determining that the preset content is included, the terminal may execute step S413 to store the domain name for which the current network request is successful, and execute step S414 to store the mapping relationship between the domain name and the IP address, so that the network request may be initiated again using the website including the IP address after the IP request fails.
It can be seen that, in the embodiment shown in fig. 4, after the terminal sends the network request using the website including a domain name, it may determine whether the domain name request is successful according to the response message returned by the server, and if the domain name request is not successful, the terminal sends the network request again using the website including the standby domain name, so that the terminal may send the network request more flexibly and effectively. If the response message is successful, the terminal needs to further determine whether the response message contains preset content, so as to ensure the validity and reliability of the acquired resource. If the preset content is contained, the terminal can store the domain name and the IP address of the server accessed when the request is successful, so that the network request can be sent again by directly utilizing the website including the IP address under the condition that the preset content is not acquired in the following process. If the returned response message does not contain the preset content, the terminal needs to determine whether the domain name has the IP address used when the corresponding network request is successful by searching the mapping relation, and if not, the terminal tries to send the domain name request of the website including the standby domain name by using the standby domain name; if the IP address exists, the terminal can use the website including the IP address to send the network request again, and if the network request fails, the terminal can try to send the domain name request of the website including the standby domain name. Of course, if the terminal does not inquire the standby domain name corresponding to the domain name, the terminal does not need to send a network request. The embodiment of the invention provides a certain solution method by combining the actual conditions of network request failure, such as domain name request failure, IP request failure and the like, and improves the request success rate of the client by using the modes of standby domain names, switching effective IP addresses and the like.
Fig. 5 is a schematic structural diagram of a request processing apparatus according to a first embodiment of the present invention. In particular, the device can be applied to various intelligent terminals, including but not limited to tablet computers, smart phones, intelligent wearable devices and other terminals. Specifically, the apparatus may include:
a sending module 10, configured to initiate a first network request using a web address including a first domain name.
A determining module 20, configured to determine, when the first network request fails, a reason for the failure of the first network request.
The sending module 10 is further configured to initiate a second network request according to the determined reason.
It should be noted that the sending module 10 may initiate the first network request by using a website including the first domain name; the determining module 20 may determine the reason for the failure of the first network request when the first network request fails, so that the sending module 10 may also initiate a second network request according to the determined reason.
In this embodiment of the present invention, the process of initiating the first network request by using the website including the first domain name may include acquiring the website including the first domain name from the terminal, and sending an HTTP request including the first domain name to the corresponding server. The first domain name is a domain name stored when the network request is successful within a preset time length. The above process of initiating the second network request according to the determined reason may include a process between acquiring a web address including an IP address from the terminal and transmitting an HTTP request including an IP address to the corresponding server, and may further include a process between acquiring a web address including a spare domain name from the terminal and transmitting an HTTP request including a spare domain name to the corresponding server.
As can be seen, in the embodiment shown in fig. 5, the terminal may initiate the first network request using the website including the first domain name, determine the reason for the failure of the first network request after the failure of the first network request, and initiate the second network request according to the determined reason, thereby improving the request success rate to a certain extent.
Fig. 6 is a schematic structural diagram of a request processing device according to a second embodiment of the present invention. In particular, the device can be applied to various intelligent terminals, including but not limited to tablet computers, mobile phones, intelligent wearable devices and other terminals. Fig. 6 is optimized on the basis of fig. 5. Wherein, this terminal includes: the device comprises a sending module 10, a determining module 20, an obtaining module 30 and a storing module 40. Specifically, the apparatus may include:
further optionally, the determining module 20 is specifically configured to determine whether a response message returned by the first network request includes preset content, and when the response message does not include the preset content, determine that the first network request failure is an IP request failure.
In this embodiment of the present invention, when the first network request fails, the determining module 20 may determine whether the first network request failure is an IP request failure by determining whether a response message returned by the server includes preset content. If the response message does not contain the preset content, it can be understood that the first network request failure is an IP request failure. After the determining module 20 determines that the first network request failure is an IP request failure, it may further determine whether there is an IP address used when the request is successful in the local cache, so as to initiate a second network request using a website including the IP address, so as to improve the request success rate.
Optionally, the sending module 10 is specifically configured to determine a pre-stored IP address when the network request by using the first domain name is successful; initiating a second network request using the web address including the IP address.
Optionally, the determining module 20 is specifically configured to determine whether a response message returned by the first network request indicates that the domain name request fails; and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
In this embodiment of the present invention, the determining module 20 may determine whether the first network request failure is a domain name request failure after the first network request failure. The domain name request failure can be judged by the state line information in the response message returned by the server. After determining that the domain name request fails, the determining module 20 may determine the standby domain name corresponding to the first domain name, so that the sending module 10 initiates the second network request, thereby increasing the request success rate.
Optionally, the sending module 10 is specifically configured to determine a standby domain name of the first domain name; and initiating a second network request by using the website comprising the standby domain name.
Optionally, the sending module 10 is specifically configured to splice the IP addresses into a uniform resource locator URL; and initiating a second network request by using the spliced URL, wherein the header information in the second network request carries the IP address.
In the embodiment of the present invention, when the sending module 10 sends the second network request using the website including the IP address, the IP address needs to replace the first domain name, and the original website including the first domain name is spliced, if the corresponding IP address is IP address 1 when the domain name a request is successful, and the website including the first domain name is http:// domain name a, after the network request using the website fails, the website is changed into http:// IP address 1 after the network request using the IP address is spliced.
Optionally, the obtaining module 30 is configured to obtain at least one standby domain name of the first domain name provided by at least one domain name provider.
Optionally, the storage module 40 is configured to store a corresponding relationship between the first domain name and the at least one standby domain name, where the corresponding relationship further includes a preset geographical range of each standby domain name.
In this embodiment of the present invention, the obtaining module 50 may obtain a standby domain name corresponding to the first domain name, which is provided by at least one domain name service provider, and store the corresponding relationship between the domain name and the standby domain name in the local storage through the storage module 40.
Optionally, the sending module 10 determines the standby domain name of the first domain name, specifically: determining a geographic location from which the first network request originated; and inquiring the standby domain name corresponding to the geographic position.
It can be seen that in the embodiment shown in fig. 6, when the first network request fails, the terminal may determine the reason of the failure of the first network request, that is, analyze whether the reason of the failure of the first network request is the domain name request failure or the IP request failure. And different solutions have been proposed for different reasons of failure. For example, the second network request is sent using the alternate domain name if the domain name request fails, and the second network request is sent using the IP address if the IP request fails. Therefore, the terminal can send the network request again by using the cached IP address and using the standby domain name, thereby improving the success rate of the network request.
Fig. 7 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention. The electronic device can be various intelligent terminals including but not limited to a tablet computer, a mobile phone, an intelligent wearable device and other terminals. Specifically, the electronic device may include: at least one processor 701, such as a Central Processing Unit (CPU), at least one communication interface 702, at least one communication bus 703, and memory 704. The communication interface 702 may include a Display (Display) and a Keyboard (Keyboard), and optionally, the communication interface 702 may also include a standard wired interface and a standard wireless interface. The communication bus 703 is used for realizing connection communication among these components. The Memory 704 may be a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The memory 704 may optionally be at least one memory device located remotely from the processor 701. Wherein a set of program codes may be stored in the memory 704, the processor 701 may call the program codes stored in the memory 704 for executing a request processing method in conjunction with the apparatus described in fig. 5 and 6, i.e. for performing the following operations:
initiating a first network request using a web site including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length; when the first network request fails, determining the reason of the failure of the first network request; initiating a second network request according to the determined reason.
In this embodiment of the present invention, the processor 701 invokes the program code in the memory 704, and the determining the reason for the failure of the first network request is further configured to:
determining whether a response message returned by the first network request comprises preset content; and when the response message does not contain preset content, determining that the first network request failure is an IP request failure.
In this embodiment of the present invention, the processor 701 invokes the program code in the memory 704, and the second network request is initiated according to the determined reason, and further performs the following operations:
determining a pre-stored Internet Protocol (IP) address when the network request by using the first domain name is successful; initiating a second network request using the web address including the IP address.
In this embodiment of the present invention, the processor 701 invokes the program code in the memory 704, and the determining the reason for the failure of the first network request is further configured to perform the following operations:
determining whether a response message returned by the first network request indicates that the domain name request fails; and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
In this embodiment of the present invention, the processor 701 invokes the program code in the memory 704, and the second network request is initiated according to the determined reason, and further performs the following operations:
determining a standby domain name of the first domain name; and initiating a second network request by using the website comprising the standby domain name.
In this embodiment of the present invention, the processor 701 invokes the program code in the memory 704, initiates the second network request by using the website address including the IP address, and is further configured to perform the following operations:
splicing the IP addresses into Uniform Resource Locators (URLs); and initiating a second network request by using the spliced URL, wherein the header information in the second network request carries the IP address.
In the embodiment of the present invention, the processor 701 invokes the program code in the memory 704, and is further configured to perform the following operations:
acquiring at least one standby domain name of the first domain name provided by at least one domain name provider; storing a correspondence between the first domain name and the at least one standby domain name in the memory 704, where the correspondence further includes a preset geographical range of each standby domain name.
In this embodiment of the present invention, the processor 701 invokes a program code in the memory 704, and determines the standby domain name of the first domain name, where the determining is further configured to perform the following operations:
determining a geographic location from which the first network request originated; and inquiring the standby domain name corresponding to the geographic position.
It can be seen that, in the embodiment shown in fig. 7, the terminal may send the first network request using the website including the first domain name, and after the first network request fails, may determine a reason why the network request by the first domain name fails, and send the second network request according to the reason. Further, if the terminal determines that the first network request failure is a domain name request failure, the terminal may use the standby domain name for the second network request. If the terminal determines that the first network request failure is an IP request failure, the terminal may send the network request again by searching for an IP address used when the network request is successful. Alternatively, the terminal may attempt to initiate the network request again with the alternate domain name after the second network request fails. Through the mode, the terminal can try to switch the IP address and use the standby domain name to initiate the network request again according to the actual situation of network request failure so as to improve the success rate of the network request and obtain the resources required by the user.
The request processing method, the request processing device and the electronic device disclosed by the embodiment of the invention are described in detail, a specific example is applied in the description to explain the principle and the implementation of the invention, and the description of the embodiment is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (9)

1. A method for processing a request, comprising:
acquiring at least one standby domain name of a first domain name provided by at least one domain name provider;
storing a corresponding relation between the first domain name and the at least one standby domain name, wherein the corresponding relation also comprises a preset geographical range of each standby domain name;
initiating a first network request using a web site including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length;
when the first network request fails, determining the reason of the failure of the first network request;
when the reason of the first network request failure is internet protocol IP request failure, determining a pre-stored internet protocol IP address when the network request by using the first domain name is successful; initiating a second network request using a web address including the IP address;
when the reason for the failure of the first network request is the failure of the domain name request, determining the geographical position for initiating the first network request; inquiring a standby domain name corresponding to the geographic position; and initiating a second network request by using the website comprising the standby domain name.
2. The method of claim 1, wherein the determining the reason for the failure of the first network request comprises:
determining whether a response message returned by the first network request comprises preset content;
and when the response message does not contain preset content, determining that the first network request failure is an Internet Protocol (IP) request failure.
3. The method of claim 1, wherein the determining the reason for the failure of the first network request comprises:
determining whether a response message returned by the first network request indicates that the domain name request fails;
and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
4. The method according to any of claims 1 to 3, wherein said initiating a second network request using a web address comprising said IP address comprises:
splicing the IP addresses into Uniform Resource Locators (URLs);
and initiating a second network request by using the spliced URL, wherein the header information in the second network request carries the IP address.
5. A request processing apparatus, comprising:
the acquisition module is used for acquiring at least one standby domain name of a first domain name provided by at least one domain name provider;
the storage module is used for storing a corresponding relation between the first domain name and the at least one standby domain name, and the corresponding relation also comprises a preset geographical range of each standby domain name;
a sending module, configured to initiate a first network request using a website including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length;
a determining module, configured to determine, when the first network request fails, a reason for the failure of the first network request;
the sending module is further configured to determine a pre-stored internet protocol IP address when the network request is successfully performed by using the first domain name when the reason for the failure of the first network request is the failure of the internet protocol IP request, and initiate a second network request by using a website including the IP address; when the reason of the first network request failure is the domain name request failure, determining the geographical position for initiating the first network request; inquiring a standby domain name corresponding to the geographic position; and initiating a second network request by using the website comprising the standby domain name.
6. The apparatus according to claim 5, wherein the determining module is specifically configured to determine whether a response message returned by the first network request includes preset content; and when the response message does not contain preset content, determining that the first network request failure is an Internet Protocol (IP) request failure.
7. The apparatus according to claim 5, wherein the determining module is specifically configured to determine whether the response message returned by the first network request indicates that the domain name request fails; and when the response message indicates that the domain name request fails, determining that the first network request fails to be the domain name request failure.
8. The apparatus according to any one of claims 5 to 7, wherein the sending module initiates the second network request by using a web address including the IP address, specifically: splicing the IP addresses into Uniform Resource Locators (URLs); and initiating a second network request by using the spliced URL, wherein the header information in the second network request carries the IP address.
9. An electronic device, comprising: a processor, a memory, a communication interface, and a communication bus; the processor, the memory and the communication interface are connected through the communication bus and complete mutual communication; the memory stores executable program code; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory for executing a request processing method; wherein the method comprises the following steps:
acquiring at least one standby domain name of a first domain name provided by at least one domain name provider;
storing a corresponding relation between the first domain name and the at least one standby domain name, wherein the corresponding relation also comprises a preset geographical range of each standby domain name;
initiating a first network request using a web site including a first domain name; the first domain name is a domain name stored when the network request is successful within a preset time length;
when the first network request fails, determining the reason of the failure of the first network request;
when the reason of the first network request failure is internet protocol IP request failure, determining a pre-stored internet protocol IP address when the network request is successfully carried out by utilizing the first domain name, and initiating a second network request by utilizing a website comprising the IP address;
when the reason for the failure of the first network request is the failure of the domain name request, determining the geographical position for initiating the first network request; inquiring a standby domain name corresponding to the geographic position; and initiating a second network request by using the website comprising the standby domain name.
CN201710210105.3A 2017-03-31 2017-03-31 Request processing method and device and electronic equipment Active CN107154963B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710210105.3A CN107154963B (en) 2017-03-31 2017-03-31 Request processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710210105.3A CN107154963B (en) 2017-03-31 2017-03-31 Request processing method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN107154963A CN107154963A (en) 2017-09-12
CN107154963B true CN107154963B (en) 2021-01-29

Family

ID=59792630

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710210105.3A Active CN107154963B (en) 2017-03-31 2017-03-31 Request processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN107154963B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107832329B (en) * 2017-09-26 2020-11-13 中国平安人寿保险股份有限公司 Page resource obtaining method and terminal equipment
CN109451053B (en) * 2018-12-18 2022-02-25 广州市百果园信息技术有限公司 Page resource request message sending method, device, medium and computer equipment
CN109743364A (en) * 2018-12-20 2019-05-10 广州市百果园信息技术有限公司 Multistep connection control method, device, computer equipment and storage medium
CN109617912B (en) * 2019-01-15 2021-05-28 成都知道创宇信息技术有限公司 Device for preventing DDoS attack by adopting intelligent switching of multiple domain names
CN110290229A (en) * 2019-06-05 2019-09-27 广东美的制冷设备有限公司 Domain name analytic method, device, electronic equipment and the storage medium of household appliance
CN112218131A (en) * 2019-07-09 2021-01-12 中国移动通信集团吉林有限公司 Set top box working method and device, electronic equipment and computer readable storage medium
CN112134958B (en) * 2020-09-23 2022-04-15 北京奇艺世纪科技有限公司 Data request method, device, server and storage medium
CN113115102B (en) * 2021-04-07 2022-04-15 湖南快乐阳光互动娱乐传媒有限公司 Streaming media playing method and device
CN114640649A (en) * 2022-03-16 2022-06-17 Oppo广东移动通信有限公司 Domain name resolution method, service terminal, electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214223A (en) * 2011-06-15 2011-10-12 奇智软件(北京)有限公司 Method and system for browser access control
CN105991797A (en) * 2016-07-01 2016-10-05 北京奇虎科技有限公司 Method and device for network access by mobile terminal

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102752267B (en) * 2011-04-20 2016-08-03 阿里巴巴集团控股有限公司 Website information provides method and device
CN103188293B (en) * 2011-12-28 2014-12-24 腾讯科技(深圳)有限公司 Method and system for allowing mobile terminal to access webpage
CN105429800A (en) * 2015-12-03 2016-03-23 小米科技有限责任公司 Network connection processing method and device and terminal equipment
CN105991798A (en) * 2016-07-01 2016-10-05 北京奇虎科技有限公司 Method and device for network access by mobile terminal

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102214223A (en) * 2011-06-15 2011-10-12 奇智软件(北京)有限公司 Method and system for browser access control
CN105991797A (en) * 2016-07-01 2016-10-05 北京奇虎科技有限公司 Method and device for network access by mobile terminal

Also Published As

Publication number Publication date
CN107154963A (en) 2017-09-12

Similar Documents

Publication Publication Date Title
CN107154963B (en) Request processing method and device and electronic equipment
CN112073405B (en) Webpage data loading method and device, computer equipment and storage medium
US8463915B1 (en) Method for reducing DNS resolution delay
US9451046B2 (en) Managing CDN registration by a storage provider
EP2985705A2 (en) Webpage access method and apparatus, and router
CN105930528B (en) Webpage caching method and server
CN102783119B (en) Access control method and system, and access terminal
WO2013131472A1 (en) Message processing method, device and system
CN113366815B (en) Network resource request method, device, electronic equipment and storage medium
CN113316926B (en) Domain name processing method, device, electronic equipment and storage medium
CN107181779B (en) Method, device and system for processing access request
CN111107176B (en) Data transmission method and device, computer equipment and storage medium
CN102904765B (en) The method and apparatus that data report
WO2015074459A1 (en) Method and apparatus for opening webpage, invoking client, and creating light app
US10015204B2 (en) Method, terminal, and server for restoring transmission of session content
CN113206785B (en) Network request method and device, terminal equipment and storage medium
CN109302437B (en) Method and device for redirecting website
CN112100541A (en) Website page element loading method and device, electronic device and storage medium
CN110933193B (en) Domain name resolution method and device, electronic equipment and computer readable storage medium
CN105279156A (en) Network information communication method and network information browsing device
CN106411978B (en) Resource caching method and device
CN103561068A (en) Method and device for improving speed of web page browsing
CN106790176B (en) Method and system for accessing network
CN108846096B (en) Webpage prompting method, terminal, gateway equipment and user edge equipment
US20080033961A1 (en) Electronic Document Browsing

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