[go: up one dir, main page]

CN108600378A - A kind of document down loading method, device, terminal and storage medium - Google Patents

A kind of document down loading method, device, terminal and storage medium Download PDF

Info

Publication number
CN108600378A
CN108600378A CN201810396790.8A CN201810396790A CN108600378A CN 108600378 A CN108600378 A CN 108600378A CN 201810396790 A CN201810396790 A CN 201810396790A CN 108600378 A CN108600378 A CN 108600378A
Authority
CN
China
Prior art keywords
target
destination
file
downloaded
network 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.)
Granted
Application number
CN201810396790.8A
Other languages
Chinese (zh)
Other versions
CN108600378B (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.)
Changsha Ningsi Information Technology Co.,Ltd.
Original Assignee
Wuhan Douyu Network 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810396790.8A priority Critical patent/CN108600378B/en
Publication of CN108600378A publication Critical patent/CN108600378A/en
Application granted granted Critical
Publication of CN108600378B publication Critical patent/CN108600378B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • 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/14Session management
    • H04L67/148Migration or transfer of sessions

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention discloses a kind of document down loading method, device, terminal and storage mediums.This method includes:Obtain the corresponding target network address of file to be downloaded;Destination request message is generated according to default requesting method and target network address, and destination request message is sent to destination server;Determine that target response code, wherein target response message are sent by destination server according to destination request message according to the target response message of reception;If target response code is transfer answer code, transfer network address is determined according to target response message, and destination request message is updated according to transfer network address, updated destination request message is sent to destination server;File to be downloaded is downloaded according to the updated target response message of reception.The technical solution of the embodiment of the present invention can solve the problems, such as that the file after redirecting can not be downloaded automatically in the prior art, realize the automatic download of file, improve download efficiency, and the user experience is improved.

Description

A kind of document down loading method, device, terminal and storage medium
Technical field
The present embodiments relate to network technologies more particularly to a kind of document down loading method, device, terminal and storage to be situated between Matter.
Background technology
With the development of network technology, user often downloads required file in the client.Currently, being based on HTTP File in (HyperText Transfer Protocol, hypertext transfer protocol) procotol download server is a kind of Most commonly seen method for down loading.
However, in the file data in downloading a specified network address, if because of the file data quilt of certain reason network address The problem of being transferred to other paths, then leading to not download file data in the network address.In general, program in the prior art Member has found that file data is transferred, that is, after network address redirection occurs, redirecting for network address is realized by writing correlative code manually It downloads.As it can be seen that in the prior art after file redirection, the automatic download of file data is cannot achieve, is downloaded to reduce Efficiency, and affect user experience.
Invention content
An embodiment of the present invention provides a kind of document down loading method, device, terminal and storage mediums, to solve the prior art In can not download automatically redirect after file data the problem of, realize the automatic download of file, to improve download effect Rate, and the user experience is improved.
In a first aspect, an embodiment of the present invention provides a kind of document down loading methods, including:
Obtain the corresponding target network address of file to be downloaded;
Destination request message is generated according to default requesting method and the target network address, and to described in destination server transmission Destination request message;
Target response code is determined according to the target response message of reception, wherein the target response message is taken by the target Business device is sent according to the destination request message;
If the target response code is transfer answer code, transfer network address, and root are determined according to the target response message The destination request message is updated according to the transfer network address, updated destination request message is sent to the destination server;
The file to be downloaded is downloaded according to the updated target response message of reception.
Second aspect, the embodiment of the present invention additionally provide a kind of file downloading device, including:
Target website acquisition module, for obtaining the corresponding target network address of file to be downloaded;
Destination request message generation module, for generating destination request report according to default requesting method and the target network address Text, and send the destination request message to destination server;
Target response code determining module, for determining target response code according to the target response message of reception, wherein described Target response message is sent by the destination server according to the destination request message;
Destination request message update module, if being transfer answer code for the target response code, according to the target Response message determines transfer network address, according to the transfer network address update destination request message, and to the destination server Send updated destination request message;
First file download module, for downloading the text to be downloaded according to the updated target response message of reception Part.
The third aspect, the embodiment of the present invention additionally provide a kind of terminal, and the terminal includes:
One or more processors;
Memory, for storing one or more programs;
When one or more of programs are executed by one or more of processors so that one or more of processing Device realizes the document down loading method as described in any embodiment of the present invention.
Fourth aspect, the embodiment of the present invention additionally provide a kind of computer readable storage medium, are stored thereon with computer Program, which is characterized in that the document down loading method as described in any embodiment of the present invention is realized when the program is executed by processor.
The embodiment of the present invention according to the target network address for presetting requesting method and file to be downloaded by generating destination request report Text, and destination request message is sent to destination server, and target response code is determined according to the target response message of reception;If mesh It is transfer answer code to mark answer code, then determines transfer network address according to target response message, updates destination request according to transfer network address Message, and updated destination request message is retransmitted to destination server, to receive updated target response message, from And file to be downloaded is downloaded according to updated target response message so that when the network address of file to be downloaded redirects, File to be downloaded can be downloaded automatically according to the transfer network address after redirection, to solve in the prior art can not it is automatic under Load-carrying orientation after file the problem of, improve download efficiency and the user experience is improved.
Description of the drawings
Fig. 1 is a kind of flow chart for document down loading method that the embodiment of the present invention one provides;
Fig. 2 is a kind of structural schematic diagram of file downloading device provided by Embodiment 2 of the present invention;
Fig. 3 is a kind of structural schematic diagram for terminal that the embodiment of the present invention three provides.
Specific implementation mode
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining the present invention rather than limitation of the invention.It also should be noted that in order to just Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
Fig. 1 is a kind of flow chart for document down loading method that the embodiment of the present invention one provides, and the present embodiment is applicable to In client the case where file in download server.This method can be executed by file downloading device, which can be by The mode of software and/or hardware is realized, is integrated in client.This method specifically includes following steps:
S110, the corresponding target network address of file to be downloaded is obtained.
Wherein, file to be downloaded refers to the HTTP files for needing to download from server using http protocol.Each wait for down Part of publishing papers corresponds to a target network address.Target network address in the present embodiment refers to the URL (Uniform based on http protocol Resoure Locator, uniform resource locator) address.The corresponding target network address of file to be downloaded can be inputted by user The mode of network address obtains, and the corresponding website links of file to be downloaded can also be clicked directly on by user to obtain.Illustratively, The entitled version.ini of file to be downloaded, wherein www indicates that the agreement of this document version.ini is http protocol, Www.douyu.com indicates that host address, i.e. domain name addresses, pcclient/version.ini indicate file to be downloaded The resource path of version.ini can be seen that file to be downloaded version.ini is stored according to the target network address Under the pcclient catalogues of this host of www.douyu.com.
S120, destination request message is generated according to default requesting method and target network address, and mesh is sent to destination server Mark request message.
Wherein, requesting method include but not limited to GET, POST, OPTIONS, HEAD, PUT, DELETE, TRACE and CONNECT.Default requesting method can be pre-set according to actual conditions and demand.Illustratively, HTTP texts usually are being downloaded GET request method is used when part.Destination request message can be directed to the HTTP message that file is downloaded in destination server request.This Destination server in embodiment refers to the corresponding HTTP server of target network address, for receiving and answer file download apparatus hair The destination request message sent.
Optionally, S120 includes:
According to the target domain name addresses in target network address, target ip address and target port are determined;Based on target ip address And target port, utilize socket and read-write service object's linking objective server;When the success of linking objective server, according to Default requesting method and target network address generate destination request message, and send destination request message to destination server.
Wherein, http protocol is assisted based on TCP (Transmission Control Protocol, transmission control protocol) The upper layer application protocol of view.Generally conventional Transmission Control Protocol is needed according to IP address and port come Connection Service device, therefore is being initiated When TCP connection, it is necessary to target ip address and target port are provided, illustratively, IP address 127.0.0.1.It is assisted based on HTTP The only domain name addresses that the target network address of view provides, to need to parse to the target domain name addresses in target network address, really Fixed target ip address corresponding with target domain name addresses and target port.Optionally, by calling gethostbyname to obtain Hostent structures, and according to the h_addr_list fields in hostent structures, parse target ip address.Specifically, passing through Gethostbyname network APs I (Application Programming Interface, application programming interface) is by mesh Mark domain name addresses is transferred to as parameter in gethostbyname functions, to obtain a hostent structured data, and root According to the h_addr_list fields in the hostent structures, inet_ntoa is called to obtain h_addr_list [0], thus by h_ The corresponding IP address of addr_list [0] is determined as the corresponding target ip address of target domain name addresses.HTTP service in the present embodiment The port of device acquiescence is 80, so as to directly determine that target port is 80.Illustratively, file to be downloaded version.ini Target network address be http://www.douyu.com/pcclient/version.ini, by by domain name addresses Www.douyu.com is transmitted to as parameter in gethostbyname functions, so that it is determined that corresponding with www.douyu.com Target ip address.According to determining target ip address and target port, TCP SOCKET sockets and I/O read-write services pair are utilized As sending TCP connection, to linking objective server.
Optionally, it is based on target ip address and target port, utilizes socket and read-write service object's linking objective service Device, including:
Create asynchronous read-write service object;Asynchronous socket is created, and read-write service object is passed to socket Constructed fuction in;The contiguous function of socket is called, and target ip address and target port are passed in contiguous function;According to Parameter information in first call back function determine destination server whether successful connection, wherein the first call back function is for receiving The connection result of contiguous function.
Wherein, the present embodiment is in linking objective server, and boost is used to increase income the library ASIO (asynchronous IO) in library. Optionally, by new operators, it is boost to create a type::asio::The asynchronous read-write service pair of io_service As can read-write service object be labeled as m_ioService.By new operators, it is boost to create a type:: asio::ip::tcp::The asynchronous socket of socket, and the m_ioService of establishment read-write service objects are passed to this In the constructed fuction of type, read-write service object can take as first parameter of the constructed fuction, and by incoming read-write The socket of business object, which can mark, is.By calling the contiguous function in the socket m_socket created, such as Target ip address and target port are passed into the contiguous function by async_connect functions, with linking objective server. The contiguous function of socket is for realizing the asynchronous connection to destination server in the present embodiment, it is also necessary to provide one The call back function of OnConnectResult is connect with judging whether the execution of the contiguous function succeeds using the first call back function Receive the connection result of the contiguous function.Optionally, when entering the first call back function, by judging in the first call back function Error parameter informations whether equal to 0 come determine destination server whether successful connection.If error parameter informations are equal to 0, table Show linking objective server success, if error parameter informations be not equal to 0, then it represents that linking objective serv-fail, need again into The connection of row destination server.
Optionally, after the success of linking objective server, it is also necessary to initiate a network and read request of data, to prepare to connect It receives to connect the response data of destination server.Receiver function namely in calling socket, such as async_read_some When function, an asynchronous exclusive rights request is delivered in read-write service object.And when calling receiver function, it is also desirable to carry For the call back function of an OnRecvMessage, to receive the network data of destination server transmission.Socket in the present embodiment In receiver function async_read_some be for realizing the network data that destination server is sent Asynchronous Reception and under It carries.
Optionally, it is GET methods to preset requesting method;Correspondingly, generating mesh according to default requesting method and target network address Request message is marked, and destination request message is sent to destination server, including:
According to target network address, the heads GET and host head are constructed;According to the heads GET and host head, destination request is determined Header;According to the transmission function in socket, destination request header is sent to destination server.
Wherein, after the success of linking objective server, destination request message can be sent to destination server.When default When request method is GET methods, the HTTP request header data of text type are typically sent to destination server.This It needs to use " r n " line feed in request message head in embodiment, and there are one without any at the end of text data " r n " newline of data.When constructing the heads GET, it is necessary to be started with GET character strings, add the master in target network address later The version number of machine title and http protocol.When constructing the head host (Host), started with Host character strings, adds target later Host address in network address.Illustratively, if target network address is http://www.douyu.com/pcclient/ Version.ini, then the heads GET constructed be GET pcclient/version.ini HTTP/1.1 r n, the host of construction Head is Host:www.douyu.com\r\n.After the heads GET constructed, the host header constructed is and then added Portion, so that it is determined that the text-string of destination request header.By calling the transmission function in socket, such as async_ The text-string of destination request header is sent to destination server by write_some functions.It is socketed in the present embodiment Transmission function async_write_some in word is for realizing the asynchronous transmission to request data.
Optionally, after S120, further include:
The receiver function in socket is called, and the target response that destination server is sent is received using the second call back function Message.
Wherein, after destination request message being sent to destination server, if destination server responds successfully, target clothes Business device sends target response message corresponding with destination request message to file downloading device.The present embodiment can be covered by calling The receiver function async_read_some in word is met, when destination server responds successfully, just enters the second call back function OnRecvMessage come receive destination server transmission target response message.
S130, target response code is determined according to the target response message of reception, wherein target response message is by destination service Device is sent according to destination request message.
Wherein, the target response message in the present embodiment refers to that destination server is generated and sent according to destination request message Http response message.Target response code can be the request results for describing to send the when of asking to destination server and return, It may determine that destination server is successfully to have handled request according to target response code, mistake still occur.When receiving mesh When marking response message, target response message is parsed, determines the target response code in destination request message.In target response In message, started with HTTP version numbers, after HTTP version numbers followed by be exactly target response code.Illustratively, if target is rung Answer in message is " HTTP/1.1200 ", it is determined that target response code is 200, if in target response message being " HTTP/1.1 302 ", it is determined that target response code is 302.When target response code is 200, indicate that destination server is successfully processed request. If target response code is 302, then it represents that redirection mistake has occurred in the target network address of file to be downloaded, i.e. target network address has occurred Transfer.
If S140, target response code be transfer answer code, according to target response message determine transfer network address, and according to turn It moves network address and updates destination request message, and updated destination request message is sent to destination server.
Wherein, transfer answer code refers to corresponding answer code when network address shifts, the transfer answer code in the present embodiment Can be 302.When target response code is transfer answer code, shows that redirection mistake has occurred, i.e., be nothing according to target network address Method successfully downloads file to be downloaded, needs to determine transfer network address according to target response message at this time.Optionally, to target response Location location fields in header are parsed, and the transfer network address after redirecting is obtained.Illustratively, to be downloaded The destination address of file version.ini is http://www.douyu.com/pcclient/version.ini indicates to wait for File version.ini is downloaded to be stored under the pcclient catalogues of this host of www.douyu.com, if because of certain reason, File to be downloaded version.ini is moved under pcclient2 catalogues, then in the target response header obtained at this time Location location fields are " Location:http://www.douyu.com/pcclient2/version.ini ", according to Location field can determine that transfer network address is http://www.douyu.com/pcclient2/version.ini, to File to be downloaded version.ini can be re-downloaded according to transfer network address.Transfer network address more fresh target is asked in the present embodiment It refers to that target network address is updated to transfer network address to seek message, and reenters S120, according to default requesting method and updated Target network address generates updated destination request message, and sends updated destination request message again to destination server, To receive the updated target response message that destination server is sent according to updated destination request message.
S150, file to be downloaded is downloaded according to the updated target response message of reception.
Wherein, the target response code in the updated target response message obtained according to transfer network address is success response code 200, i.e., successfully obtain the file resource of file to be downloaded.In the present embodiment, it can also first judge updated target Whether the target response code in response message is success response code, if so, being downloaded further according to updated target response message File to be downloaded, to ensure to download the accuracy of file.
Optionally, S150 includes:
In the predetermined position of disk, a file destination identical with file to be downloaded title in transfer network address is created; The target sizes information of file to be downloaded is determined according to the length field information in the head of updated target response message;It adjusts With the poll methods in the receiver function of socket and read-write service object, and under target sizes information is passed in receiver function Carry the data information of file to be downloaded;Data information after download is written into file destination.
Wherein, the predeterminated position of disk refers to the download location of file to be downloaded, and predeterminated position can be user according to reality Storage location in the disk that border demand is chosen in advance.Updated target network address is parsed to obtain the text of file to be downloaded Part title, such as version.ini.By calling fopen functions, one and this document title are created in the predetermined position of disk Identical file destination, such as version.ini files.Since the target response code in updated target response message is successfully Answer code certainly exists length field information, such as Content- in the head of the updated target response message then obtained Length fields determine the target sizes information of file to be downloaded according to Content-Length fields at this time.Illustratively, If the Content-Length fields obtained are " Content-Length:1000 ", then show the target sizes of file to be downloaded For 1000 bytes.Target sizes information in the present embodiment can determine before creating file destination, can also create mesh It marks file to determine later, sequencing of the present embodiment to the determination step of target sizes information and the foundation step of file destination It is not specifically limited.
Need to call the poll methods in the receiver function and read-write service object of socket in the present embodiment simultaneously so that Second call back function OnRecvMessage receives the file data that destination server is sent, if only calling the reception letter of socket Number, and the poll methods in never call read-write service object, then the second call back function OnRecvMessage is can not to receive text Number of packages evidence.The poll methods in receiver function async_read_some and read-write service object by calling socket, and Target sizes information is passed in receiver function async_read_some, so as to utilize the second call back function OnRecvMessage receives the data information of file to be downloaded, when downloaded byte amount is equal to target sizes information, indicates File to be downloaded, which is downloaded, to be completed.After the completion of downloading the data information of file to be downloaded on destination server, pass through calling The data information of file to be downloaded is written in the file destination of establishment by fwrite functions, to store file to be downloaded.This Embodiment is when downloading HTTP files, if redirection mistake has occurred, can parse the transfer net after redirecting automatically Location, and re-downloaded automatically according to transfer network address, to solve the file that can not be downloaded automatically in the prior art after redirecting The problem of, download efficiency is greatly accelerated, and the user experience is improved.
It should be noted that calling contiguous function async_connect, the receiver function of socket in the present embodiment Async_read_some and transmission function async_write_some is asynchronous, so needing to call read-write service object Poll methods all asynchronous events of socket are handled.
Optionally, if target response code is success response code, file to be downloaded is directly downloaded according to target response message.
Wherein, the success response code in the present embodiment can be 200.If target response code in target response message be at Work(answer code, then it represents that file to be downloaded does not occur to redirect mistake, at this time can be directly according to target response message come under Carry file to be downloaded.The process that file is directly downloaded according to target response message is downloaded with according to updated target response message The process of file is similar, specially:In the predetermined position of disk, one and file to be downloaded title phase in target network address are created Same file destination;The target sizes letter of file to be downloaded is determined according to the length field information in the head of target response message Breath;The poll methods in the receiver function and read-write service object of socket are called, and target sizes information is passed to and receives letter The data information of file to be downloaded is downloaded in number;Data information after download is written into file destination.The present embodiment can be with By judging that target response code is transfer answer code or success response code, to be downloaded automatically according to different target response codes File, to improve the stability and applicability of download system operation.
The technical solution of the present embodiment, by generating target according to the target network address for presetting requesting method and file to be downloaded Request message, and destination request message is sent to destination server, and target response is determined according to the target response message of reception Code;If target response code is transfer answer code, transfer network address is determined according to target response message, mesh is updated according to transfer network address Request message is marked, and updated destination request message is retransmitted to destination server, to receive updated target response Message, to download file to be downloaded according to updated target response message so that sent out in the target network address of file to be downloaded When raw redirection, file to be downloaded can be downloaded automatically according to the transfer network address after redirection, to solve the prior art In can not download automatically redirect after file the problem of, improve download efficiency and the user experience is improved.
Embodiment two
Fig. 2 is a kind of structural schematic diagram of file downloading device provided by Embodiment 2 of the present invention, and the present embodiment is applicable In download server in the client the case where file, which includes:Target website acquisition module 210, destination request report Literary generation module 220, target response code determining module 230, destination request message update module 240 and the first file download module 250。
Wherein, target website acquisition module 210, for obtaining the corresponding target network address of file to be downloaded;Destination request report Literary generation module 220 for generating destination request message according to default requesting method and target network address, and is sent out to destination server Send destination request message;Target response code determining module 230, for determining target response according to the target response message of reception Code, wherein target response message are sent by destination server according to destination request message;Destination request message update module 240, If being transfer answer code for target response code, transfer network address is determined according to target response message, and more according to transfer network address Fresh target request message, and send updated destination request message to destination server;First file download module 250 is used According to the updated target response message of reception download file to be downloaded.
Optionally, destination request message generation module 220, including:
Target ip address determination unit, for according to the target domain name addresses in target network address, determine target ip address and Target port;
Destination server connection unit is serviced for being based on target ip address and target port using socket and read-write Object linking objective server;
Destination server connection unit, when for the success of linking objective server, according to default requesting method and target network Location generates destination request message, and sends destination request message to destination server.
Optionally, destination server connection unit is specifically used for:
Create asynchronous read-write service object;Asynchronous socket is created, and read-write service object is passed to socket Constructed fuction in;The contiguous function of socket is called, and target ip address and target port are passed in contiguous function;According to Parameter information in first call back function determine destination server whether successful connection, wherein the first call back function is for receiving The connection result of contiguous function.
Optionally, it is GET methods to preset requesting method;Correspondingly, destination request message generation unit, is specifically used for:
According to target network address, the heads GET and host head are constructed;According to the heads GET and host head, destination request is determined Header;According to the transmission function in socket, destination request header is sent to destination server.
Optionally, which further includes:
Target response message receiving module, for after sending destination request message to destination server, calling socket Receiver function in word, and receive the target response message that destination server is sent using the second call back function.
Optionally, the first file download module 250, is specifically used for:
In the predetermined position of disk, a file destination identical with file to be downloaded title in transfer network address is created;
Determine that the target of file to be downloaded is big according to the length field information in the head of updated target response message Small information;
The poll methods in the receiver function and read-write service object of socket are called, and target sizes information is passed to and is connect Receive the data information that file to be downloaded is downloaded in function;
Data information after download is written into file destination.
Optionally, which further includes:
Second file download module, if being success response code for target response code, directly according to target response message Download file to be downloaded.
Above-mentioned file downloading device can perform the document down loading method that any embodiment of the present invention is provided, and has and executes text The corresponding function module of part method for down loading and advantageous effect.
Embodiment three
Fig. 3 is a kind of structural schematic diagram for terminal that the embodiment of the present invention three provides.Referring to Fig. 3, which includes:
One or more processors 310;
Memory 320, for storing one or more programs;
When one or more programs are executed by one or more processors 310 so that one or more processors 310 are realized Such as the document down loading method that any embodiment proposes in above-described embodiment.
In Fig. 3 by taking a processor 310 as an example;Processor 310 and memory 320 in terminal can by bus or its He connects mode, in Fig. 3 for being connected by bus.
Memory 320 is used as a kind of computer readable storage medium, can be used for storing software program, computer can perform journey Sequence and module, if the corresponding program instruction/module of the document down loading method in the embodiment of the present invention is (for example, file download fills Target website acquisition module 210, destination request message generation module 220, target response code determining module 230, target in setting Request message update module 240 and the first file download module 250).Processor 310 is stored in by operation in memory 320 Software program, instruction and module realize above-mentioned text to execute various function application and the data processing of terminal Part method for down loading.
Memory 320 includes mainly storing program area and storage data field, wherein storing program area can store operation system Application program needed for system, at least one function;Storage data field can be stored uses created data etc. according to terminal.This Outside, memory 320 may include high-speed random access memory, can also include nonvolatile memory, for example, at least one Disk memory, flush memory device or other non-volatile solid state memory parts.In some instances, memory 320 can be into one Step includes the memory remotely located relative to processor 310, these remote memories can pass through network connection to terminal.On The example for stating network includes but not limited to internet, intranet, LAN, mobile radio communication and combinations thereof.
The document down loading method that the terminal that the present embodiment proposes is proposed with above-described embodiment belongs to same inventive concept, does not exist The technical detail of detailed description can be found in above-described embodiment in the present embodiment, and the present embodiment has execution document down loading method Identical advantageous effect.
Example IV
The present embodiment provides a kind of computer readable storage mediums, are stored thereon with computer program, which is handled The document down loading method as described in any embodiment of the present invention is realized when device executes.
The arbitrary of one or more computer-readable media may be used in the computer storage media of the embodiment of the present invention Combination.Computer-readable medium can be computer-readable signal media or computer readable storage medium.It is computer-readable Storage medium can be for example but not limited to:System, device or the device of electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor, or The arbitrary above combination of person.The more specific example (non exhaustive list) of computer readable storage medium includes:There are one tools Or the electrical connections of multiple conducting wires, portable computer diskette, hard disk, random access memory (RAM), read-only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light Memory device, magnetic memory device or above-mentioned any appropriate combination.In this document, computer readable storage medium can With to be any include or the tangible medium of storage program, the program can be commanded execution system, device or device use or Person is in connection.
Computer-readable signal media may include in a base band or as the data-signal that a carrier wave part is propagated, Wherein carry computer-readable program code.Diversified forms may be used in the data-signal of this propagation, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By instruction execution system, device either device use or program in connection.
The program code for including on computer-readable medium can transmit with any suitable medium, including but not limited to: Wirelessly, electric wire, optical cable, RF etc. or above-mentioned any appropriate combination.
It can be write with one or more programming languages or combinations thereof for executing the computer that operates of the present invention Program code, described program design language include object oriented program language, such as Java, Smalltalk, C++, also Including conventional procedural programming language-such as " C " language or similar programming language.Program code can be complete It executes, partly executed on the user computer on the user computer entirely, being executed as an independent software package, part Part executes or executes on a remote computer or server completely on the remote computer on the user computer.It is relating to And in the situation of remote computer, remote computer can pass through the network of any kind, including LAN (LAN) or wide area network (WAN), it is connected to subscriber computer, or, it may be connected to outer computer (such as led to using ISP Cross internet connection).
Above-described embodiment serial number is for illustration only, can not represent the quality of embodiment.
Will be appreciated by those skilled in the art that each module of the above invention or each step can use general meter Device is calculated to realize, they can be concentrated on single computing device, or be distributed in network constituted by multiple computing devices On, optionally, they can be realized with the program code that computer installation can perform, so as to be stored in storage It is performed by computing device in device, either they are fabricated to each integrated circuit modules or will be more in them A module or step are fabricated to single integrated circuit module to realize.In this way, the present invention is not limited to any specific hardware and The combination of software.
Each embodiment in this specification is described in a progressive manner, the highlights of each of the examples are with The difference of other embodiment, just to refer each other for the same or analogous part between each embodiment.
Note that above are only presently preferred embodiments of the present invention and institute's application technology principle.It will be appreciated by those skilled in the art that The present invention is not limited to specific embodiments described here, can carry out for a person skilled in the art it is various it is apparent variation, It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out to the present invention by above example It is described in further detail, but the present invention is not limited only to above example, without departing from the inventive concept, also May include other more equivalent embodiments, and the scope of the present invention is determined by scope of the appended claims.

Claims (10)

1. a kind of document down loading method, which is characterized in that including:
Obtain the corresponding target network address of file to be downloaded;
Destination request message is generated according to default requesting method and the target network address, and the target is sent to destination server Request message;
Target response code is determined according to the target response message of reception, wherein the target response message is by the destination server It is sent according to the destination request message;
If the target response code is transfer answer code, transfer network address is determined according to the target response message, and according to institute It states transfer network address and updates the destination request message, updated destination request message is sent to the destination server;
The file to be downloaded is downloaded according to the updated target response message of reception.
2. according to the method described in claim 1, it is characterized in that, generating mesh according to default requesting method and the target network address Request message is marked, and the destination request message is sent to destination server, including:
According to the target domain name addresses in the target network address, target ip address and target port are determined;
Based on the target ip address and the target port, socket and read-write service object's linking objective server are utilized;
When connecting the destination server success, destination request report is generated according to default requesting method and the target network address Text, and send the destination request message to the destination server.
3. according to the method described in claim 2, it is characterized in that, be based on the target ip address and the target port, profit With socket and service object's linking objective server is read and write, including:
Create asynchronous read-write service object;
Asynchronous socket is created, and the read-write service object is passed into the constructed fuction of the socket;
The contiguous function of the socket is called, and the target ip address and the target port are passed to the contiguous function In;
According to the parameter information in the first call back function determine the destination server whether successful connection, wherein described first Call back function is used to receive the connection result of the contiguous function.
4. according to the method described in claim 2, it is characterized in that, the default requesting method is GET methods;
Correspondingly, generate destination request message according to default requesting method and the target network address, and to the destination server The destination request message is sent, including:
According to the target network address, the heads GET and host head are constructed;
According to the heads GET and the host head, destination request header is determined;
According to the transmission function in the socket, the destination request header is sent to the destination server.
5. according to the method described in claim 2, it is characterized in that, sending the destination request report to the destination server After text, further include:
The receiver function in the socket is called, and the target that the destination server is sent is received using the second call back function Response message.
6. according to the method described in claim 2, it is characterized in that, downloading institute according to the updated target response message of reception File to be downloaded is stated, including:
In the predetermined position of disk, a file destination identical with file to be downloaded title in the transfer network address is created;
Determine that the target of the file to be downloaded is big according to the length field information in the head of updated target response message Small information;
The poll methods in the receiver function and the read-write service object of the socket are called, and the target sizes are believed Breath is passed to the data information that the file to be downloaded is downloaded in the receiver function;
Data information after download is written into the file destination.
7. according to any methods of claim 1-6, which is characterized in that the method further includes:
If the target response code is success response code, the text to be downloaded is directly downloaded according to the target response message Part.
8. a kind of file downloading device, which is characterized in that including:
Target website acquisition module, for obtaining the corresponding target network address of file to be downloaded;
Destination request message generation module, for generating destination request message according to default requesting method and the target network address, And send the destination request message to destination server;
Target response code determining module, for determining target response code according to the target response message of reception, wherein the target Response message is sent by the destination server according to the destination request message;
Destination request message update module, if being transfer answer code for the target response code, according to the target response Message determines transfer network address, and updates the destination request message according to the transfer network address, is sent to the destination server Updated destination request message;
First file download module, for downloading the file to be downloaded according to the updated target response message of reception.
9. a kind of terminal, which is characterized in that the terminal includes:
One or more processors;
Memory, for storing one or more programs;
When one or more of programs are executed by one or more of processors so that one or more of processors are real The now document down loading method as described in any in claim 1-7.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is by processor The document down loading method as described in any in claim 1-7 is realized when execution.
CN201810396790.8A 2018-04-28 2018-04-28 File downloading method, device, terminal and storage medium Active CN108600378B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810396790.8A CN108600378B (en) 2018-04-28 2018-04-28 File downloading method, device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810396790.8A CN108600378B (en) 2018-04-28 2018-04-28 File downloading method, device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN108600378A true CN108600378A (en) 2018-09-28
CN108600378B CN108600378B (en) 2021-05-28

Family

ID=63611000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810396790.8A Active CN108600378B (en) 2018-04-28 2018-04-28 File downloading method, device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN108600378B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111813851A (en) * 2020-05-25 2020-10-23 车智互联(北京)科技有限公司 Method and system for synchronizing data to webpage by mobile application and mobile terminal
CN112788141A (en) * 2021-01-18 2021-05-11 苏州浪潮智能科技有限公司 File downloading method, device, equipment and computer readable storage medium
CN112818336A (en) * 2020-12-28 2021-05-18 深圳市金微蓝技术有限公司 Data access method, data access device and computer readable storage medium
CN112968919A (en) * 2019-12-12 2021-06-15 上海欣诺通信技术股份有限公司 Data processing method, device, equipment and storage medium
CN115695411A (en) * 2022-09-21 2023-02-03 中国工商银行股份有限公司 Data processing method and device, electronic equipment and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120102221A1 (en) * 2010-10-25 2012-04-26 Google Inc. System and method for redirecting a request for a non-canonical web page
CN104219311A (en) * 2014-09-05 2014-12-17 四川长虹电器股份有限公司 Method and system for downloading television application
CN104270440A (en) * 2014-09-26 2015-01-07 郭丹 Portal processing method of portable broadband wireless access equipment
CN104426718A (en) * 2013-09-10 2015-03-18 方正宽带网络服务股份有限公司 Data monitoring server, cache server and redirection downloading method
CN104468363A (en) * 2013-09-18 2015-03-25 华为终端有限公司 Page redirection method, page redirection system, router equipment and terminal equipment
CN106557584A (en) * 2016-11-29 2017-04-05 青岛海信移动通信技术股份有限公司 A kind of web site collection method and device
CN106874471A (en) * 2017-02-16 2017-06-20 北京百度网讯科技有限公司 Information-pushing method and device
CN107196986A (en) * 2016-03-15 2017-09-22 中国移动通信集团江苏有限公司 A kind of reorientation method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120102221A1 (en) * 2010-10-25 2012-04-26 Google Inc. System and method for redirecting a request for a non-canonical web page
CN104426718A (en) * 2013-09-10 2015-03-18 方正宽带网络服务股份有限公司 Data monitoring server, cache server and redirection downloading method
CN104468363A (en) * 2013-09-18 2015-03-25 华为终端有限公司 Page redirection method, page redirection system, router equipment and terminal equipment
CN104219311A (en) * 2014-09-05 2014-12-17 四川长虹电器股份有限公司 Method and system for downloading television application
CN104270440A (en) * 2014-09-26 2015-01-07 郭丹 Portal processing method of portable broadband wireless access equipment
CN107196986A (en) * 2016-03-15 2017-09-22 中国移动通信集团江苏有限公司 A kind of reorientation method and device
CN106557584A (en) * 2016-11-29 2017-04-05 青岛海信移动通信技术股份有限公司 A kind of web site collection method and device
CN106874471A (en) * 2017-02-16 2017-06-20 北京百度网讯科技有限公司 Information-pushing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JENG-WEI LIN等: ""A Web redirection service for variant Chinese domain name resolution"", 《THIRD INTERNATIONAL CONFERENCE ON INFORMATION TECHNOLOGY AND APPLICATIONS (ICITA"05)》 *
王海燕 , 张华贵: ""在asp.net中实现重定向的方法与技巧"", 《电脑知识与技术:学术交流》 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112968919A (en) * 2019-12-12 2021-06-15 上海欣诺通信技术股份有限公司 Data processing method, device, equipment and storage medium
CN112968919B (en) * 2019-12-12 2023-05-30 上海欣诺通信技术股份有限公司 Data processing method, device, equipment and storage medium
CN111813851A (en) * 2020-05-25 2020-10-23 车智互联(北京)科技有限公司 Method and system for synchronizing data to webpage by mobile application and mobile terminal
CN111813851B (en) * 2020-05-25 2023-10-20 车智互联(北京)科技有限公司 Method, system and mobile terminal for synchronizing data from mobile application to webpage
CN112818336A (en) * 2020-12-28 2021-05-18 深圳市金微蓝技术有限公司 Data access method, data access device and computer readable storage medium
CN112788141A (en) * 2021-01-18 2021-05-11 苏州浪潮智能科技有限公司 File downloading method, device, equipment and computer readable storage medium
CN112788141B (en) * 2021-01-18 2022-07-05 苏州浪潮智能科技有限公司 File downloading method, device, equipment and computer readable storage medium
CN115695411A (en) * 2022-09-21 2023-02-03 中国工商银行股份有限公司 Data processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN108600378B (en) 2021-05-28

Similar Documents

Publication Publication Date Title
CN108600378A (en) A kind of document down loading method, device, terminal and storage medium
CN102904959B (en) Network accelerating method and gateway
US20230291741A1 (en) System and method to securely execute datacenter management operations remotely
US8893027B2 (en) Providing hosted virtual desktop infrastructure services
CN109067914A (en) Proxy Method, device, equipment and the storage medium of Web service
CN110601952A (en) Multi-channel message notification sending method and device
CN110769009B (en) User identity authentication method and system
CN112565439A (en) Internet of things communication method and system
CN108600377B (en) Method, device, terminal and storage medium for suspending file downloading
CN105812481A (en) Hypertext transfer protocol request identification system and hypertext transfer protocol request identification method
US10291718B2 (en) Method and apparatus for implementing communication from web page to client
US20040040022A1 (en) Method and apparatus for just-in-time provisioning application-related information at a communication device
CN108366112A (en) Data transmission method and system, the medium and computing device of client
EP2445171B1 (en) File transfer protocol client and implementing method thereof
US20110264770A1 (en) Apparatus and method for cooperatively operating web browser and local resource in mobile terminal
CN102904935B (en) Downloading method, downloading device and downloading system based on home gateway
CN112422566B (en) Remote call processing method and device, storage medium and electronic device
CN106445700B (en) A kind of URL matching process and device
CN113824756B (en) File processing method, device, storage medium and electronic device
CN111953793B (en) Application distribution method, device, terminal and storage medium
CN116846935A (en) Device adding system, method, device, electronic device and storage medium
US8761818B2 (en) Converged dialog in hybrid mobile applications
CN113157285A (en) Program file package installation method, storage medium, electronic device and system
CN110769065A (en) Remote management method, system, terminal equipment and server
CN103118042B (en) Application on site service system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240709

Address after: 508 Accelerator Production Workshop, Building B-2, Haichuang Technology Industrial Park, No. 627 Lugu Avenue, High tech Development Zone, Changsha City, Hunan Province, China 410000

Patentee after: Changsha Ningsi Information Technology Co.,Ltd.

Country or region after: China

Address before: 11 / F, building B1, phase 4.1, software industry, No.1, Software Park East Road, Wuhan East Lake Development Zone, Wuhan City, Hubei Province, 430070

Patentee before: WUHAN DOUYU NETWORK TECHNOLOGY Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right