mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-22 05:43:22 +01:00
133 lines
5.1 KiB
Java
133 lines
5.1 KiB
Java
package org.apache.http.config;
|
|
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.charset.CodingErrorAction;
|
|
import org.apache.http.Consts;
|
|
import org.apache.http.annotation.Contract;
|
|
import org.apache.http.annotation.ThreadingBehavior;
|
|
import org.apache.http.util.Args;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@Contract(threading = ThreadingBehavior.IMMUTABLE)
|
|
/* loaded from: classes11.dex */
|
|
public class ConnectionConfig implements Cloneable {
|
|
public static final ConnectionConfig DEFAULT = new Builder().build();
|
|
private final int bufferSize;
|
|
private final Charset charset;
|
|
private final int fragmentSizeHint;
|
|
private final CodingErrorAction malformedInputAction;
|
|
private final MessageConstraints messageConstraints;
|
|
private final CodingErrorAction unmappableInputAction;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class Builder {
|
|
private int bufferSize;
|
|
private Charset charset;
|
|
private int fragmentSizeHint = -1;
|
|
private CodingErrorAction malformedInputAction;
|
|
private MessageConstraints messageConstraints;
|
|
private CodingErrorAction unmappableInputAction;
|
|
|
|
public ConnectionConfig build() {
|
|
Charset charset = this.charset;
|
|
if (charset == null && (this.malformedInputAction != null || this.unmappableInputAction != null)) {
|
|
charset = Consts.ASCII;
|
|
}
|
|
Charset charset2 = charset;
|
|
int i = this.bufferSize;
|
|
if (i <= 0) {
|
|
i = 8192;
|
|
}
|
|
int i2 = i;
|
|
int i3 = this.fragmentSizeHint;
|
|
return new ConnectionConfig(i2, i3 >= 0 ? i3 : i2, charset2, this.malformedInputAction, this.unmappableInputAction, this.messageConstraints);
|
|
}
|
|
|
|
public Builder setBufferSize(int i) {
|
|
this.bufferSize = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder setCharset(Charset charset) {
|
|
this.charset = charset;
|
|
return this;
|
|
}
|
|
|
|
public Builder setFragmentSizeHint(int i) {
|
|
this.fragmentSizeHint = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder setMalformedInputAction(CodingErrorAction codingErrorAction) {
|
|
this.malformedInputAction = codingErrorAction;
|
|
if (codingErrorAction != null && this.charset == null) {
|
|
this.charset = Consts.ASCII;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public Builder setMessageConstraints(MessageConstraints messageConstraints) {
|
|
this.messageConstraints = messageConstraints;
|
|
return this;
|
|
}
|
|
|
|
public Builder setUnmappableInputAction(CodingErrorAction codingErrorAction) {
|
|
this.unmappableInputAction = codingErrorAction;
|
|
if (codingErrorAction != null && this.charset == null) {
|
|
this.charset = Consts.ASCII;
|
|
}
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public ConnectionConfig(int i, int i2, Charset charset, CodingErrorAction codingErrorAction, CodingErrorAction codingErrorAction2, MessageConstraints messageConstraints) {
|
|
this.bufferSize = i;
|
|
this.fragmentSizeHint = i2;
|
|
this.charset = charset;
|
|
this.malformedInputAction = codingErrorAction;
|
|
this.unmappableInputAction = codingErrorAction2;
|
|
this.messageConstraints = messageConstraints;
|
|
}
|
|
|
|
public static Builder copy(ConnectionConfig connectionConfig) {
|
|
Args.notNull(connectionConfig, "Connection config");
|
|
return new Builder().setBufferSize(connectionConfig.getBufferSize()).setCharset(connectionConfig.getCharset()).setFragmentSizeHint(connectionConfig.getFragmentSizeHint()).setMalformedInputAction(connectionConfig.getMalformedInputAction()).setUnmappableInputAction(connectionConfig.getUnmappableInputAction()).setMessageConstraints(connectionConfig.getMessageConstraints());
|
|
}
|
|
|
|
public static Builder custom() {
|
|
return new Builder();
|
|
}
|
|
|
|
public ConnectionConfig clone() throws CloneNotSupportedException {
|
|
return (ConnectionConfig) super.clone();
|
|
}
|
|
|
|
public int getBufferSize() {
|
|
return this.bufferSize;
|
|
}
|
|
|
|
public Charset getCharset() {
|
|
return this.charset;
|
|
}
|
|
|
|
public int getFragmentSizeHint() {
|
|
return this.fragmentSizeHint;
|
|
}
|
|
|
|
public CodingErrorAction getMalformedInputAction() {
|
|
return this.malformedInputAction;
|
|
}
|
|
|
|
public MessageConstraints getMessageConstraints() {
|
|
return this.messageConstraints;
|
|
}
|
|
|
|
public CodingErrorAction getUnmappableInputAction() {
|
|
return this.unmappableInputAction;
|
|
}
|
|
|
|
public String toString() {
|
|
return "[bufferSize=" + this.bufferSize + ", fragmentSizeHint=" + this.fragmentSizeHint + ", charset=" + this.charset + ", malformedInputAction=" + this.malformedInputAction + ", unmappableInputAction=" + this.unmappableInputAction + ", messageConstraints=" + this.messageConstraints + MarkdownConstants.RIGHT_BRACKET;
|
|
}
|
|
}
|