Package org.apache.mina.http.api

Examples of org.apache.mina.http.api.HttpEndOfContent


            // compute content len
            headers.put("Content-Length", String.valueOf(content.remaining()));
            session.write(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SUCCESS_OK, headers));
            session.write(new HttpContentChunk(content));
            session.write(new HttpEndOfContent());
            session.close(false);

        }
View Full Code Here


                return chunk;

            }
            break;
        case DONE:
            return new HttpEndOfContent();
        default:
            throw new IllegalStateException("Unknonwn decoder state : " + context.getState());
        }

        return null;
View Full Code Here

            // compute content len
            headers.put("Content-Length", String.valueOf(content.remaining()));
            session.write(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SUCCESS_OK, headers));
            session.write(content);
            session.write(new HttpEndOfContent());
        }
View Full Code Here

                session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
                session.removeAttribute(BODY_REMAINING_BYTES);
                if( session.getAttribute(BODY_CHUNKED) != null ) {
                    session.removeAttribute(BODY_CHUNKED);
                }
                out.write(new HttpEndOfContent());
            } else {
                if( session.getAttribute(BODY_CHUNKED) == null ) {
                    session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining));
                }
            }
View Full Code Here

                    session.setAttribute(DECODER_STATE_ATT, DecoderState.BODY);
                    // fallthrough, process body immediately
                } else {
                    LOG.debug("request without content");
                    session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
                    out.write(new HttpEndOfContent());
                    break;
                }
            }

        case BODY:
            LOG.debug("decoding BODY: {} bytes", msg.remaining());
            final int chunkSize = msg.remaining();
            // send the chunk of body
            if (chunkSize != 0) {
                final IoBuffer wb = IoBuffer.allocate(msg.remaining());
                wb.put(msg);
                wb.flip();
                out.write(wb);
            }
            msg.position(msg.limit());
            // do we have reach end of body ?
            int remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES);
            remaining -= chunkSize;

            if (remaining <= 0) {
                LOG.debug("end of HTTP body");
                session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
                session.removeAttribute(BODY_REMAINING_BYTES);
                out.write(new HttpEndOfContent());
            } else {
                session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining));
            }

            break;
View Full Code Here

                session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
                session.removeAttribute(BODY_REMAINING_BYTES);
                if( session.getAttribute(BODY_CHUNKED) != null ) {
                  session.removeAttribute(BODY_CHUNKED);
                }
                out.write(new HttpEndOfContent());
            } else {
              if( session.getAttribute(BODY_CHUNKED) == null ) {
                session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining));
              }
            }
View Full Code Here

                        throw new HttpException(HttpStatus.CLIENT_ERROR_LENGTH_REQUIRED, "no content length !");
                    }
                } else {
                    LOG.debug("request without content");
                    session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
                    out.write(new HttpEndOfContent());
                }
            }

            break;

        case BODY:
            LOG.debug("decoding BODY: {} bytes", msg.remaining());
            final int chunkSize = msg.remaining();
            // send the chunk of body
            if (chunkSize != 0) {
              final IoBuffer wb = IoBuffer.allocate(msg.remaining());
          wb.put(msg);
          wb.flip();
          out.write(wb);
            }
            msg.position(msg.limit());
            // do we have reach end of body ?
            int remaining = (Integer) session.getAttribute(BODY_REMAINING_BYTES);
            remaining -= chunkSize;

            if (remaining <= 0) {
                LOG.debug("end of HTTP body");
                session.setAttribute(DECODER_STATE_ATT, DecoderState.NEW);
                session.removeAttribute(BODY_REMAINING_BYTES);
                out.write(new HttpEndOfContent());
            } else {
                session.setAttribute(BODY_REMAINING_BYTES, Integer.valueOf(remaining));
            }

            break;
View Full Code Here

TOP

Related Classes of org.apache.mina.http.api.HttpEndOfContent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.