Home / File/ SmtpRequestEncoder.java — netty Source File

SmtpRequestEncoder.java — netty Source File

Architecture documentation for SmtpRequestEncoder.java, a java file in the netty codebase.

Entity Profile

Relationship Graph

Source Code

/*
 * Copyright 2016 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.handler.codec.smtp;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import io.netty.util.LeakPresenceDetector;
import io.netty.util.internal.UnstableApi;

import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;

/**
 * Encoder for SMTP requests.
 */
@UnstableApi
public final class SmtpRequestEncoder extends MessageToMessageEncoder<Object> {
    private static final int CRLF_SHORT = ('\r' << 8) | '\n';
    private static final byte SP = ' ';
    private static final ByteBuf DOT_CRLF_BUFFER = LeakPresenceDetector.staticInitializer(() ->
            Unpooled.unreleasableBuffer(Unpooled.directBuffer(3)
                    .writeByte('.').writeByte('\r').writeByte('\n')).asReadOnly());

    private boolean contentExpected;

    public SmtpRequestEncoder() {
        super(Object.class);
    }

    @Override
    public boolean acceptOutboundMessage(Object msg) throws Exception {
        return msg instanceof SmtpRequest || msg instanceof SmtpContent;
    }

    @Override
    protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception {
        if (msg instanceof SmtpRequest) {
            final SmtpRequest req = (SmtpRequest) msg;
            if (contentExpected) {
                if (req.command().equals(SmtpCommand.RSET)) {
                    contentExpected = false;
                } else {
                    throw new IllegalStateException("SmtpContent expected");
// ... (62 more lines)

Domain

Subdomains

Frequently Asked Questions

What does SmtpRequestEncoder.java do?
SmtpRequestEncoder.java is a source file in the netty codebase, written in java. It belongs to the Buffer domain, Allocators subdomain.
Where is SmtpRequestEncoder.java in the architecture?
SmtpRequestEncoder.java is located at codec-smtp/src/main/java/io/netty/handler/codec/smtp/SmtpRequestEncoder.java (domain: Buffer, subdomain: Allocators, directory: codec-smtp/src/main/java/io/netty/handler/codec/smtp).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free