void uncheckedAddContent(int b) { _buffer.put((byte)b); }
_header.put(_method); _header.put((byte)' '); _header.put(_uri.getBytes("utf-8")); // TODO WRONG! _header.put(HttpTokens.CRLF); _state = STATE_FLUSHING; _noContent=true; _header.put(_method); _header.put((byte)' '); _header.put(_uri.getBytes("utf-8")); // TODO WRONG! _header.put((byte)' '); _header.put(_version==HttpVersions.HTTP_1_0_ORDINAL?HttpVersions.HTTP_1_0_BUFFER:HttpVersions.HTTP_1_1_BUFFER); _header.put(HttpTokens.CRLF); _header.put(HttpVersions.HTTP_1_1_BUFFER); _header.put((byte) ' '); _header.put((byte) ('0' + _status / 100)); _header.put((byte) ('0' + (_status % 100) / 10)); _header.put((byte) ('0' + (_status % 10))); _header.put((byte) ' '); if (_reason==null) _header.put((byte) ('0' + _status / 100)); _header.put((byte) ('0' + (_status % 100) / 10)); _header.put((byte) ('0' + (_status % 10))); _header.put(_reason); _header.put(HttpTokens.CRLF);
buffer.put((byte)'-'); buffer.put((byte)(0x7f&'8')); buffer.put((byte)(0x7f&'0')); buffer.put((byte)(0x7f&'0')); buffer.put((byte)(0x7f&'0')); buffer.put((byte)(0x7f&'0')); buffer.put((byte)(0x7f&'0')); buffer.put((byte)(0x7f&'0')); buffer.put((byte)(0x7f&'0')); buffer.put(DIGIT[n]); buffer.put((byte)'0'); continue; buffer.put(DIGIT[d]); n= n - d * hexDivisors[i];
/** * @param status The status code to send. * @param reason the status message to send. */ public void setResponse(int status, String reason) { if (_state != STATE_HEADER) throw new IllegalStateException("STATE!=START"); _status = status; if (reason!=null) { int len=reason.length(); if (len>_headerBufferSize/2) len=_headerBufferSize/2; _reason=new ByteArrayBuffer(len); for (int i=0;i<len;i++) { char ch = reason.charAt(i); if (ch!='\r'&&ch!='\n') _reason.put((byte)ch); else _reason.put((byte)' '); } } }
public int fill(Buffer buffer) throws IOException { if (_closed) throw new IOException("CLOSED"); if (_in==null) return -1; if (_in.length()<=0) return _nonBlocking?0:-1; int len = buffer.put(_in); _in.skip(len); return len; }
/** * @param contentBufferSize The contentBufferSize to set. */ public void increaseContentBufferSize(int contentBufferSize) { if (contentBufferSize > _contentBufferSize) { _contentBufferSize = contentBufferSize; if (_buffer != null) { Buffer nb = _buffers.getBuffer(_contentBufferSize); nb.put(_buffer); _buffers.returnBuffer(_buffer); _buffer = nb; } } }
int len = _buffer.put(_content); _content.skip(len); if (_content.length() == 0) _header.put(HttpTokens.CRLF); _needCRLF = false; _header.put(HttpTokens.CRLF); _buffer.put(HttpTokens.CRLF); else _needCRLF = true; _header.put(HttpTokens.CRLF); _needCRLF = false; _buffer.put(HttpTokens.CRLF); _needCRLF = false; _header.put(LAST_CHUNK); _bufferChunked=true; _buffer.put(LAST_CHUNK); _bufferChunked=true;
int len=_buffer.put(_content); _content.skip(len); if (_content.length() == 0)
_header.compact(); _body.skip(_header.put(_body));