jdk/src/java.base/share/classes/sun/security/timestamp/HttpTimestamper.java
changeset 32933 83d50f1247bb
parent 30374 2abaf49910ea
equal deleted inserted replaced
32932:9250ad475b43 32933:83d50f1247bb
    25 
    25 
    26 package sun.security.timestamp;
    26 package sun.security.timestamp;
    27 
    27 
    28 import java.io.BufferedInputStream;
    28 import java.io.BufferedInputStream;
    29 import java.io.DataOutputStream;
    29 import java.io.DataOutputStream;
       
    30 import java.io.EOFException;
    30 import java.io.IOException;
    31 import java.io.IOException;
    31 import java.net.URI;
    32 import java.net.URI;
    32 import java.net.URL;
    33 import java.net.URL;
    33 import java.net.HttpURLConnection;
    34 import java.net.HttpURLConnection;
    34 import java.util.*;
    35 import java.util.*;
    35 
    36 
    36 import sun.misc.IOUtils;
       
    37 import sun.security.util.Debug;
    37 import sun.security.util.Debug;
    38 
    38 
    39 /**
    39 /**
    40  * A timestamper that communicates with a Timestamping Authority (TSA)
    40  * A timestamper that communicates with a Timestamping Authority (TSA)
    41  * over HTTP.
    41  * over HTTP.
   145                 }
   145                 }
   146                 debug.println();
   146                 debug.println();
   147             }
   147             }
   148             verifyMimeType(connection.getContentType());
   148             verifyMimeType(connection.getContentType());
   149 
   149 
   150             int contentLength = connection.getContentLength();
   150             int clen = connection.getContentLength();
   151             replyBuffer = IOUtils.readFully(input, contentLength, false);
   151             replyBuffer = input.readAllBytes();
       
   152             if (clen != -1 && replyBuffer.length != clen)
       
   153                 throw new EOFException("Expected:" + clen +
       
   154                                        ", read:" + replyBuffer.length);
   152 
   155 
   153             if (debug != null) {
   156             if (debug != null) {
   154                 debug.println("received timestamp response (length=" +
   157                 debug.println("received timestamp response (length=" +
   155                         replyBuffer.length + ")");
   158                         replyBuffer.length + ")");
   156             }
   159             }