import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo

This commit is contained in:
Roy Tam 2018-01-19 03:59:58 +08:00
commit dcd9973243
150858 changed files with 23884658 additions and 0 deletions

View file

@ -0,0 +1,192 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package ch.boye.httpclientandroidlib.config;
import java.nio.charset.Charset;
import java.nio.charset.CodingErrorAction;
import ch.boye.httpclientandroidlib.Consts;
import ch.boye.httpclientandroidlib.annotation.Immutable;
import ch.boye.httpclientandroidlib.util.Args;
/**
* HTTP connection configuration.
*
* @since 4.3
*/
@Immutable
public class ConnectionConfig implements Cloneable {
public static final ConnectionConfig DEFAULT = new Builder().build();
private final int bufferSize;
private final int fragmentSizeHint;
private final Charset charset;
private final CodingErrorAction malformedInputAction;
private final CodingErrorAction unmappableInputAction;
private final MessageConstraints messageConstraints;
ConnectionConfig(
final int bufferSize,
final int fragmentSizeHint,
final Charset charset,
final CodingErrorAction malformedInputAction,
final CodingErrorAction unmappableInputAction,
final MessageConstraints messageConstraints) {
super();
this.bufferSize = bufferSize;
this.fragmentSizeHint = fragmentSizeHint;
this.charset = charset;
this.malformedInputAction = malformedInputAction;
this.unmappableInputAction = unmappableInputAction;
this.messageConstraints = messageConstraints;
}
public int getBufferSize() {
return bufferSize;
}
public int getFragmentSizeHint() {
return fragmentSizeHint;
}
public Charset getCharset() {
return charset;
}
public CodingErrorAction getMalformedInputAction() {
return malformedInputAction;
}
public CodingErrorAction getUnmappableInputAction() {
return unmappableInputAction;
}
public MessageConstraints getMessageConstraints() {
return messageConstraints;
}
@Override
protected ConnectionConfig clone() throws CloneNotSupportedException {
return (ConnectionConfig) super.clone();
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("[bufferSize=").append(this.bufferSize)
.append(", fragmentSizeHint=").append(this.fragmentSizeHint)
.append(", charset=").append(this.charset)
.append(", malformedInputAction=").append(this.malformedInputAction)
.append(", unmappableInputAction=").append(this.unmappableInputAction)
.append(", messageConstraints=").append(this.messageConstraints)
.append("]");
return builder.toString();
}
public static ConnectionConfig.Builder custom() {
return new Builder();
}
public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
Args.notNull(config, "Connection config");
return new Builder()
.setCharset(config.getCharset())
.setMalformedInputAction(config.getMalformedInputAction())
.setUnmappableInputAction(config.getUnmappableInputAction())
.setMessageConstraints(config.getMessageConstraints());
}
public static class Builder {
private int bufferSize;
private int fragmentSizeHint;
private Charset charset;
private CodingErrorAction malformedInputAction;
private CodingErrorAction unmappableInputAction;
private MessageConstraints messageConstraints;
Builder() {
this.fragmentSizeHint = -1;
}
public Builder setBufferSize(final int bufferSize) {
this.bufferSize = bufferSize;
return this;
}
public Builder setFragmentSizeHint(final int fragmentSizeHint) {
this.fragmentSizeHint = fragmentSizeHint;
return this;
}
public Builder setCharset(final Charset charset) {
this.charset = charset;
return this;
}
public Builder setMalformedInputAction(final CodingErrorAction malformedInputAction) {
this.malformedInputAction = malformedInputAction;
if (malformedInputAction != null && this.charset == null) {
this.charset = Consts.ASCII;
}
return this;
}
public Builder setUnmappableInputAction(final CodingErrorAction unmappableInputAction) {
this.unmappableInputAction = unmappableInputAction;
if (unmappableInputAction != null && this.charset == null) {
this.charset = Consts.ASCII;
}
return this;
}
public Builder setMessageConstraints(final MessageConstraints messageConstraints) {
this.messageConstraints = messageConstraints;
return this;
}
public ConnectionConfig build() {
Charset cs = charset;
if (cs == null && (malformedInputAction != null || unmappableInputAction != null)) {
cs = Consts.ASCII;
}
final int bufSize = this.bufferSize > 0 ? this.bufferSize : 8 * 1024;
final int fragmentHintSize = this.fragmentSizeHint >= 0 ? this.fragmentSizeHint : bufSize;
return new ConnectionConfig(
bufSize,
fragmentHintSize,
cs,
malformedInputAction,
unmappableInputAction,
messageConstraints);
}
}
}

View file

@ -0,0 +1,40 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package ch.boye.httpclientandroidlib.config;
/**
* Generic lookup by low-case string ID.
*
* @since 4.3
*/
public interface Lookup<I> {
I lookup(String name);
}

View file

@ -0,0 +1,113 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package ch.boye.httpclientandroidlib.config;
import ch.boye.httpclientandroidlib.util.Args;
/**
* HTTP Message constraints: line length and header count.
*
* @since 4.3
*/
public class MessageConstraints implements Cloneable {
public static final MessageConstraints DEFAULT = new Builder().build();
private final int maxLineLength;
private final int maxHeaderCount;
MessageConstraints(final int maxLineLength, final int maxHeaderCount) {
super();
this.maxLineLength = maxLineLength;
this.maxHeaderCount = maxHeaderCount;
}
public int getMaxLineLength() {
return maxLineLength;
}
public int getMaxHeaderCount() {
return maxHeaderCount;
}
@Override
protected MessageConstraints clone() throws CloneNotSupportedException {
return (MessageConstraints) super.clone();
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("[maxLineLength=").append(maxLineLength)
.append(", maxHeaderCount=").append(maxHeaderCount)
.append("]");
return builder.toString();
}
public static MessageConstraints lineLen(final int max) {
return new MessageConstraints(Args.notNegative(max, "Max line length"), -1);
}
public static MessageConstraints.Builder custom() {
return new Builder();
}
public static MessageConstraints.Builder copy(final MessageConstraints config) {
Args.notNull(config, "Message constraints");
return new Builder()
.setMaxHeaderCount(config.getMaxHeaderCount())
.setMaxLineLength(config.getMaxLineLength());
}
public static class Builder {
private int maxLineLength;
private int maxHeaderCount;
Builder() {
this.maxLineLength = -1;
this.maxHeaderCount = -1;
}
public Builder setMaxLineLength(final int maxLineLength) {
this.maxLineLength = maxLineLength;
return this;
}
public Builder setMaxHeaderCount(final int maxHeaderCount) {
this.maxHeaderCount = maxHeaderCount;
return this;
}
public MessageConstraints build() {
return new MessageConstraints(maxLineLength, maxHeaderCount);
}
}
}

View file

@ -0,0 +1,63 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package ch.boye.httpclientandroidlib.config;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import ch.boye.httpclientandroidlib.annotation.ThreadSafe;
/**
* Generic registry of items keyed by low-case string ID.
*
* @since 4.3
*/
@ThreadSafe
public final class Registry<I> implements Lookup<I> {
private final Map<String, I> map;
Registry(final Map<String, I> map) {
super();
this.map = new ConcurrentHashMap<String, I>(map);
}
public I lookup(final String key) {
if (key == null) {
return null;
}
return map.get(key.toLowerCase(Locale.US));
}
@Override
public String toString() {
return map.toString();
}
}

View file

@ -0,0 +1,72 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package ch.boye.httpclientandroidlib.config;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
import ch.boye.httpclientandroidlib.util.Args;
/**
* Builder for {@link Registry} instances.
*
* @since 4.3
*/
@NotThreadSafe
public final class RegistryBuilder<I> {
private final Map<String, I> items;
public static <I> RegistryBuilder<I> create() {
return new RegistryBuilder<I>();
}
RegistryBuilder() {
super();
this.items = new HashMap<String, I>();
}
public RegistryBuilder<I> register(final String id, final I item) {
Args.notEmpty(id, "ID");
Args.notNull(item, "Item");
items.put(id.toLowerCase(Locale.US), item);
return this;
}
public Registry<I> build() {
return new Registry<I>(items);
}
@Override
public String toString() {
return items.toString();
}
}

View file

@ -0,0 +1,197 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package ch.boye.httpclientandroidlib.config;
import ch.boye.httpclientandroidlib.annotation.Immutable;
import ch.boye.httpclientandroidlib.util.Args;
/**
* Socket configuration.
*
* @since 4.3
*/
@Immutable
public class SocketConfig implements Cloneable {
public static final SocketConfig DEFAULT = new Builder().build();
private final int soTimeout;
private final boolean soReuseAddress;
private final int soLinger;
private final boolean soKeepAlive;
private final boolean tcpNoDelay;
SocketConfig(
final int soTimeout,
final boolean soReuseAddress,
final int soLinger,
final boolean soKeepAlive,
final boolean tcpNoDelay) {
super();
this.soTimeout = soTimeout;
this.soReuseAddress = soReuseAddress;
this.soLinger = soLinger;
this.soKeepAlive = soKeepAlive;
this.tcpNoDelay = tcpNoDelay;
}
/**
* Determines the default socket timeout value for non-blocking I/O operations.
* <p/>
* Default: <code>0</code> (no timeout)
*
* @see java.net.SocketOptions#SO_TIMEOUT
*/
public int getSoTimeout() {
return soTimeout;
}
/**
* Determines the default value of the {@link java.net.SocketOptions#SO_REUSEADDR} parameter
* for newly created sockets.
* <p/>
* Default: <code>false</code>
*
* @see java.net.SocketOptions#SO_REUSEADDR
*/
public boolean isSoReuseAddress() {
return soReuseAddress;
}
/**
* Determines the default value of the {@link java.net.SocketOptions#SO_LINGER} parameter
* for newly created sockets.
* <p/>
* Default: <code>-1</code>
*
* @see java.net.SocketOptions#SO_LINGER
*/
public int getSoLinger() {
return soLinger;
}
/**
* Determines the default value of the {@link java.net.SocketOptions#SO_KEEPALIVE} parameter
* for newly created sockets.
* <p/>
* Default: <code>-1</code>
*
* @see java.net.SocketOptions#SO_KEEPALIVE
*/
public boolean isSoKeepAlive() {
return this.soKeepAlive;
}
/**
* Determines the default value of the {@link java.net.SocketOptions#TCP_NODELAY} parameter
* for newly created sockets.
* <p/>
* Default: <code>false</code>
*
* @see java.net.SocketOptions#TCP_NODELAY
*/
public boolean isTcpNoDelay() {
return tcpNoDelay;
}
@Override
protected SocketConfig clone() throws CloneNotSupportedException {
return (SocketConfig) super.clone();
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("[soTimeout=").append(this.soTimeout)
.append(", soReuseAddress=").append(this.soReuseAddress)
.append(", soLinger=").append(this.soLinger)
.append(", soKeepAlive=").append(this.soKeepAlive)
.append(", tcpNoDelay=").append(this.tcpNoDelay)
.append("]");
return builder.toString();
}
public static SocketConfig.Builder custom() {
return new Builder();
}
public static SocketConfig.Builder copy(final SocketConfig config) {
Args.notNull(config, "Socket config");
return new Builder()
.setSoTimeout(config.getSoTimeout())
.setSoReuseAddress(config.isSoReuseAddress())
.setSoLinger(config.getSoLinger())
.setSoKeepAlive(config.isSoKeepAlive())
.setTcpNoDelay(config.isTcpNoDelay());
}
public static class Builder {
private int soTimeout;
private boolean soReuseAddress;
private int soLinger;
private boolean soKeepAlive;
private boolean tcpNoDelay;
Builder() {
this.soLinger = -1;
this.tcpNoDelay = true;
}
public Builder setSoTimeout(final int soTimeout) {
this.soTimeout = soTimeout;
return this;
}
public Builder setSoReuseAddress(final boolean soReuseAddress) {
this.soReuseAddress = soReuseAddress;
return this;
}
public Builder setSoLinger(final int soLinger) {
this.soLinger = soLinger;
return this;
}
public Builder setSoKeepAlive(final boolean soKeepAlive) {
this.soKeepAlive = soKeepAlive;
return this;
}
public Builder setTcpNoDelay(final boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay;
return this;
}
public SocketConfig build() {
return new SocketConfig(soTimeout, soReuseAddress, soLinger, soKeepAlive, tcpNoDelay);
}
}
}

View file

@ -0,0 +1,31 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
/**
* Core configuration APIs.
*/
package ch.boye.httpclientandroidlib.config;