Keep file download custom connection supports Flashget breakpoint renewable multi-thread link download! JSPservlet implementatio

zhaozj2021-02-16  104

<% / * File name can be stored as: Download.JSP HTTP protocol request and response session procedure can be downloaded by using Flashget to download the HTTP: // connection: The blue portion is: the client requests the purple portion: server side Response as shown in Figure: http://blog.9cbs.net/mages/blog_9cbs_net/playyueer/30110/o_flashget.gif or see, the back FlashGet session list: * / / / / / / / The file on your server and its path String s = "i: //setupres//sun//j2re-1_4_2_05-windows-i586-p.exe"; // String s = "E: //tree.mdb"; // Test RandomaccessFile can also be achieved, Interested in removing comments and comes out of the FileInputStream version of the statement //java.io.randomaccessFile Raf = new java.io.randomaccessFile (s, "r"); java.io.file f = new java.io.file (s); java.io.fileinputStream FII = new java.io.fileinputStream (f); response.reset (); response.setheader ("Server", "Playyuer@microshaoft.com"); // Tell the client to allow Breakpoints Continued Multiple Thread Connection Download // Response Formats: // Accept-Ranges: Bytes Response.setHeader ("Accept-Ranges", "Bytes"); long P = 0; long L = 0; // L = Raf.Length (); L = f.Length (); // If it is the first time, there is no breakpoint, the status is the default 200, there is no need to explicit setting // response format: // HTTP / 1.1 200 OK IF (Request.getHeader ("Range"! = Null) // The start byte of the downloaded file block of the client request {// If it is the scope of the download file, not all, to the client Support and start file block download // The format to set the status // response is: //http/1.1 206 Partial Content Response.SetStatus (javax.servlet.http.httpservletResponse.sc_partial_content); // 206 // Request from the starting byte // request The format is: // Range: Bytes = [File block start byte] - P = long.parselong (Request.getHeader ("Range"). ReplaceAll ("Bytes =", "). Replaceall (" - ", ""));} // Download file (or block) length // Response format is: // Content-Length: [Total size of files] - [Start byte of the file block of the client request] Response.setHeader ("Content-Length", New Long ()); if (p! = 0) {// is not from the first download, // response format: // Content- Range: Bytes [File Block Start byte] - [Total Size of File - 1] / [Total Size of File] Response.setHeader ("

Content-Range "," Bytes " New long (p) .tostring () " - " new long (l -1) .tostring () " / " new long (l) .tostring ()); } //Response.setheader ("Connection "," close "); // If there is this sentence, if you can't download / / to download the client directly download // respond to the format: // Content-Type: Application / OcTet-stream response.setContentType ("Application / Oct-stream"); ​​/ / Download the Default Download File Name / / Response to the Client Add: // Content-Disposition: attachment; filename = "[File Name] "//Response.setheader (" talkth-disposition "," attachment; filename = / "" s.substring (s.lastIndexof ("//") 1) "/" "); // Test RandomaccessFile It can also be implemented, interested in removing the comment and comment out the FileInputStream version of the statement response.setheader ("Content-Disposition", "Attachment; filename = /" f.getName () "/" "); / /RAF.Seek (P); Fis.skip (p); byte [] b = new byte [1024]; int i; // while ((i = raf.read (b))! = -1) // Testing RandomaccessFile can also be implemented, interested in removing the comment and commenting out the FileInputStream version of the statement while ((i = fis.read (b))! = -1) {response.getOutputStream (). Write (b, 0 , i);} //raf.close();// Test RandomaccessFile can also be implemented, interested to remove the comment and comment out the FileInputStream version Statement fis.close ();%> ======================================== ==================================

In a set of direct downloads in FlashGet, there is no breakpoint to return HTTP session: client request: MON aug 02 05:46:36 2004 is connected Download2.Flashfxp.com:80Mon aug 02 05:46:36 2004 is connected Download2.flashfxp.com [ip = 66.98.228.125: 80] MON AUG 02 05:46:37 2004 connected .mon aug 02 05:46:37 2004 get /zip/flashfxp_30_setup.exe http / 1.1mon aug 02 05:46:37 2004 Host: Download2.flashfxp.common aug 02 05:46:37 2004 Accept: * / * mon aug 02 05:46:37 2004 Referer: http://playyuer.microshaoft.common aug 02 05 : 46: 37 2004 User-Agent: Mozilla / 4.0 (Compatible; Msie 5.00; Windows 98) MON AUG 02 05:46:37 2004 Pragma: no-cachemon aug 02 05:46:37 2004 Cache-Control: no-cachemon Aug 02 05:46:37 2004 Authorization: Basic mgrhetpjy2zfzg93bmxvywq = mon Aug 02 05:46:37 2004 Connection: Close server side response: MON aug 02 05:46:37 2004 http / 1.1 200 okmon aug 02 05:46:37 2004 Date: Sun, 01 AUG 2004 21:46:29 Gmtmon Aug 02 05:46:37 2004 Server: Apache / 1.3.27 (UNIX) (Red-Hat / Linux) Mod_Fastcgi / 2.2.12 MOD_GZIP / 1.3.19.1A MOD_JK / 1.2.0 MOD_PERL / 1.26 PHP / 4.3.3 FrontPage / 5.0.2 MOD_SSL / 2.8.12 OpenSSL / 0.9.6bmon aug 02 05:46:37 2004 Last-Modified: Fri, 30 Jul 2004 18:41:18 gmtmon aug 02 05:46:37 2004 ETAG: "4F80FA-1ECF20-410A964E" MON AUG 02 05:46: 37 2004 Accept-Ranges: Bytesmon Aug 02 05:46:37 2004 Content-Length: 2019104Mon aug 02 05:46:37 2004 Connection: Closemon Aug 02 05:46:37 2004 Content-Type: Application / OcTet-Stream HTTP session process of breakpoint: client request: MON aug 02 05:27:05 2004 is connected Download2.flashfxp.com:80Mon aug 02 05:27:05 2004 is connected to download2.flashfxp.com [ip =

转载请注明原文地址:https://www.9cbs.com/read-11258.html

New Post(0)