private HTTPResponseHeader MakeHeader(string httpVersion, string mimeType, string statusCode) { HTTPResponseHeader header = new HTTPResponseHeader(httpVersion, statusCode); header.SetField(HTTPResponseHeader.SERVER_NAME_FIELD, ServerName); header.SetField(HTTPResponseHeader.CONTENT_TYPE_FIELD, mimeType); header.SetField(HTTPResponseHeader.ACCEPT_RANGES_FIELD, ACCEPT_RANGES_SUFFIX); if (AttachLastModifiedField) { header.SetField(HTTPResponseHeader.LAST_MODIFIED_FIELD, LastModified); } return(header); }
protected HTTPResponseHeader MakeHeader(string httpVersion, string mimeType, string statusCode, string location) { HTTPResponseHeader header = MakeHeader(httpVersion, mimeType, statusCode); header.SetField(HTTPResponseHeader.LOCATION_FIELD, location); return(header); }
/// <summary> /// Return stream which at first gives bytes from header encoded given encoding /// and when it ends read bytes from given string /// </summary> /// <param name="header"></param> /// <param name="stream"></param> public HTTPResponse(HTTPResponseHeader header, Stream stream, Encoding encoding) { try { _streamLength = stream.Length; } catch (NotSupportedException) { throw new StreamTypeException(LENGTH_ERROR_MESSAGE); } header.SetField(HTTPResponseHeader.CONTENT_LENGTH_FIELD, _streamLength.ToString()); this._header = encoding.GetBytes(header.ToString()); if (!stream.CanRead) { throw new StreamTypeException(READ_ERROR_MESSAGE); } internalStream = stream; _position = 0; _headerLength = this._header.LongLength; }