View Javadoc
1   package ca.uhn.hl7v2.hoh.encoder;
2   
3   import ca.uhn.hl7v2.hoh.util.VersionLogger;
4   
5   public class Hl7OverHttpResponseEncoder extends AbstractHl7OverHttpEncoder {
6   
7   	private boolean myAddConnectionCloseHeader;
8   
9   	@Override
10  	protected void addSpecificHeaders() {
11  		getHeaders().put("Server", "HAPI (HL7 over HTTP) Server " + VersionLogger.getVersion());
12  		if (isGzipData()) {
13  			getHeaders().put("Content-Encoding", "gzip");
14  		}
15  		if (myAddConnectionCloseHeader) {
16  			getHeaders().put("Connection", "close");
17  		}
18  	}
19  
20  	@Override
21  	protected void setActionLineAppropriately() {
22  		ResponseCode resp = ResponseCode.detect(getMessage());
23  		setActionLine("HTTP/1.1 " + resp.getCode() + " " + resp.getMessage());
24  	}
25  
26  	/**
27  	 * Adds a header to the HTTP response: "<code>Connection: close</code>". Note that setting this to true (default is false) will ONLY add the header, it does not actually close the connection. The
28  	 * caller is responsible for that.
29  	 */
30  	public void setAddConnectionCloseHeader(boolean theAddConnectionCloseHeader) {
31  		myAddConnectionCloseHeader = theAddConnectionCloseHeader;
32  	}
33  
34  	/**
35  	 * Should response be GZipped?
36  	 */
37  	@Override
38  	public void setGzipData(boolean theGzipData) {
39  		super.setGzipData(theGzipData);
40  	}
41  
42  }