// Path: api/src/main/java/com/vlkan/hrrs/api/HttpRequestPayload.java
// public interface HttpRequestPayload {
// 
//     int getMissingByteCount();
// 
//     byte[] getBytes();
// 
//     Builder toBuilder();
// 
//     interface Builder {
// 
//         Builder setMissingByteCount(int missingByteCount);
// 
//         Builder setBytes(byte[] bytes);
// 
//         HttpRequestPayload build();
// 
//     }
// 
// }
// 
// Path: api/src/main/java/com/vlkan/hrrs/api/ImmutableHttpRequestPayload.java
// public class ImmutableHttpRequestPayload implements HttpRequestPayload {
// 
//     private final int missingByteCount;
// 
//     private final byte[] bytes;
// 
//     private ImmutableHttpRequestPayload(int missingByteCount, byte[] bytes) {
//         checkArgument(missingByteCount >= 0, "expecting: missingByteCount >= 0, found: %s", missingByteCount);
//         this.missingByteCount = missingByteCount;
//         this.bytes = checkNotNull(bytes, "bytes");
//     }
// 
//     @Override
//     public int getMissingByteCount() {
//         return missingByteCount;
//     }
// 
//     @Override
//     public byte[] getBytes() {
//         return bytes;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         ImmutableHttpRequestPayload that = (ImmutableHttpRequestPayload) o;
//         return missingByteCount == that.missingByteCount &&
//                 Arrays.equals(bytes, that.bytes);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hashCode(missingByteCount, bytes);
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects
//                 .toStringHelper(this)
//                 .add("missingByteCount", missingByteCount)
//                 .add("byteCount", bytes.length)
//                 .toString();
//     }
// 
//     @Override
//     public Builder toBuilder() {
//         Builder builder = new Builder();
//         builder.missingByteCount = missingByteCount;
//         builder.bytes = bytes;
//         return builder;
//     }
// 
//     public static Builder newBuilder() {
//         return new Builder();
//     }
// 
//     public static class Builder implements HttpRequestPayload.Builder {
// 
//         private int missingByteCount;
// 
//         private byte[] bytes;
// 
//         private Builder() {
//             // Do nothing.
//         }
// 
//         @Override
//         public Builder setMissingByteCount(int missingByteCount) {
//             this.missingByteCount = missingByteCount;
//             return this;
//         }
// 
//         @Override
//         public Builder setBytes(byte[] bytes) {
//             this.bytes = bytes;
//             return this;
//         }
// 
//         @Override
//         public ImmutableHttpRequestPayload build() {
//             return new ImmutableHttpRequestPayload(missingByteCount, bytes);
//         }
// 
//     }
// 
// }


import com.vlkan.hrrs.api.HttpRequestPayload;
import com.vlkan.hrrs.api.ImmutableHttpRequestPayload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
package com.vlkan.hrrs.servlet;



public class HrrsUrlEncodedFormHelper {

    private static final Logger LOGGER = LoggerFactory.getLogger(HrrsUrlEncodedFormHelper.class);

    public HrrsUrlEncodedFormHelper() {
        // Do nothing.
    }

    public boolean isUrlEncodedForm(String contentType) {
        if (contentType == null) {
            return false;
        }
        int semicolon = contentType.indexOf(';');
        if (semicolon >= 0) {
            contentType = contentType.substring(0, semicolon).trim();
        } else {
            contentType = contentType.trim();
        }
        return "application/x-www-form-urlencoded".equals(contentType);
    }

// Path: api/src/main/java/com/vlkan/hrrs/api/HttpRequestPayload.java
// public interface HttpRequestPayload {
// 
//     int getMissingByteCount();
// 
//     byte[] getBytes();
// 
//     Builder toBuilder();
// 
//     interface Builder {
// 
//         Builder setMissingByteCount(int missingByteCount);
// 
//         Builder setBytes(byte[] bytes);
// 
//         HttpRequestPayload build();
// 
//     }
// 
// }
// 
// Path: api/src/main/java/com/vlkan/hrrs/api/ImmutableHttpRequestPayload.java
// public class ImmutableHttpRequestPayload implements HttpRequestPayload {
// 
//     private final int missingByteCount;
// 
//     private final byte[] bytes;
// 
//     private ImmutableHttpRequestPayload(int missingByteCount, byte[] bytes) {
//         checkArgument(missingByteCount >= 0, "expecting: missingByteCount >= 0, found: %s", missingByteCount);
//         this.missingByteCount = missingByteCount;
//         this.bytes = checkNotNull(bytes, "bytes");
//     }
// 
//     @Override
//     public int getMissingByteCount() {
//         return missingByteCount;
//     }
// 
//     @Override
//     public byte[] getBytes() {
//         return bytes;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         ImmutableHttpRequestPayload that = (ImmutableHttpRequestPayload) o;
//         return missingByteCount == that.missingByteCount &&
//                 Arrays.equals(bytes, that.bytes);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hashCode(missingByteCount, bytes);
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects
//                 .toStringHelper(this)
//                 .add("missingByteCount", missingByteCount)
//                 .add("byteCount", bytes.length)
//                 .toString();
//     }
// 
//     @Override
//     public Builder toBuilder() {
//         Builder builder = new Builder();
//         builder.missingByteCount = missingByteCount;
//         builder.bytes = bytes;
//         return builder;
//     }
// 
//     public static Builder newBuilder() {
//         return new Builder();
//     }
// 
//     public static class Builder implements HttpRequestPayload.Builder {
// 
//         private int missingByteCount;
// 
//         private byte[] bytes;
// 
//         private Builder() {
//             // Do nothing.
//         }
// 
//         @Override
//         public Builder setMissingByteCount(int missingByteCount) {
//             this.missingByteCount = missingByteCount;
//             return this;
//         }
// 
//         @Override
//         public Builder setBytes(byte[] bytes) {
//             this.bytes = bytes;
//             return this;
//         }
// 
//         @Override
//         public ImmutableHttpRequestPayload build() {
//             return new ImmutableHttpRequestPayload(missingByteCount, bytes);
//         }
// 
//     }
// 
// }


// Path: servlet-filter/src/main/java/com/vlkan/hrrs/servlet/HrrsUrlEncodedFormHelper.java
import com.vlkan.hrrs.api.HttpRequestPayload;
import com.vlkan.hrrs.api.ImmutableHttpRequestPayload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

package com.vlkan.hrrs.servlet;



public class HrrsUrlEncodedFormHelper {

    private static final Logger LOGGER = LoggerFactory.getLogger(HrrsUrlEncodedFormHelper.class);

    public HrrsUrlEncodedFormHelper() {
        // Do nothing.
    }

    public boolean isUrlEncodedForm(String contentType) {
        if (contentType == null) {
            return false;
        }
        int semicolon = contentType.indexOf(';');
        if (semicolon >= 0) {
            contentType = contentType.substring(0, semicolon).trim();
        } else {
            contentType = contentType.trim();
        }
        return "application/x-www-form-urlencoded".equals(contentType);
    }

    public HttpRequestPayload extractUrlEncodedFormPayload(HttpServletRequest request, String defaultEncoding) {