29 import java.nio.*; |
29 import java.nio.*; |
30 import java.nio.channels.*; |
30 import java.nio.channels.*; |
31 import java.net.*; |
31 import java.net.*; |
32 import javax.net.ssl.*; |
32 import javax.net.ssl.*; |
33 import java.util.*; |
33 import java.util.*; |
|
34 import java.util.logging.Logger; |
34 import java.text.*; |
35 import java.text.*; |
35 import sun.net.www.MessageHeader; |
36 import sun.net.www.MessageHeader; |
36 import com.sun.net.httpserver.*; |
37 import com.sun.net.httpserver.*; |
37 import com.sun.net.httpserver.spi.*; |
38 import com.sun.net.httpserver.spi.*; |
38 |
39 |
202 OutputStream tmpout = new BufferedOutputStream (ros); |
203 OutputStream tmpout = new BufferedOutputStream (ros); |
203 PlaceholderOutputStream o = getPlaceholderResponseBody(); |
204 PlaceholderOutputStream o = getPlaceholderResponseBody(); |
204 tmpout.write (bytes(statusLine, 0), 0, statusLine.length()); |
205 tmpout.write (bytes(statusLine, 0), 0, statusLine.length()); |
205 boolean noContentToSend = false; // assume there is content |
206 boolean noContentToSend = false; // assume there is content |
206 rspHdrs.set ("Date", df.format (new Date())); |
207 rspHdrs.set ("Date", df.format (new Date())); |
|
208 |
|
209 /* check for response type that is not allowed to send a body */ |
|
210 |
|
211 if ((rCode>=100 && rCode <200) /* informational */ |
|
212 ||(rCode == 204) /* no content */ |
|
213 ||(rCode == 304)) /* not modified */ |
|
214 { |
|
215 if (contentLen != -1) { |
|
216 Logger logger = server.getLogger(); |
|
217 String msg = "sendResponseHeaders: rCode = "+ rCode |
|
218 + ": forcing contentLen = -1"; |
|
219 logger.warning (msg); |
|
220 } |
|
221 contentLen = -1; |
|
222 } |
207 if (contentLen == 0) { |
223 if (contentLen == 0) { |
208 if (http10) { |
224 if (http10) { |
209 o.setWrappedStream (new UndefLengthOutputStream (this, ros)); |
225 o.setWrappedStream (new UndefLengthOutputStream (this, ros)); |
210 close = true; |
226 close = true; |
211 } else { |
227 } else { |