本文整理匯總了Java中org.apache.http.Consts.ASCII屬性的典型用法代碼示例。如果您正苦於以下問題:Java Consts.ASCII屬性的具體用法?Java Consts.ASCII怎麽用?Java Consts.ASCII使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.http.Consts
的用法示例。
在下文中一共展示了Consts.ASCII屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handle
@Override
public void handle(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
final String creds = (String) context.getAttribute("creds");
if (creds == null || !creds.equals("test:test")) {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
// Make client re-authenticate on each fourth request
if (this.count.incrementAndGet() % 4 == 0) {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
final StringEntity entity = new StringEntity("success", Consts.ASCII);
response.setEntity(entity);
}
}
}
示例2: testResponseParsingWithTooMuchGarbage
@Test(expected=ProtocolException.class)
public void testResponseParsingWithTooMuchGarbage() throws Exception {
final String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"HTTP/1.1 200 OK\r\n" +
"header1: value1\r\n" +
"header2: value2\r\n" +
"\r\n";
final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer) {
@Override
protected boolean reject(final CharArrayBuffer line, final int count) {
return count >= 2;
}
};
parser.parse();
}
示例3: setMalformedInputAction
public Builder setMalformedInputAction(final CodingErrorAction malformedInputAction) {
this.malformedInputAction = malformedInputAction;
if (malformedInputAction != null && this.charset == null) {
this.charset = Consts.ASCII;
}
return this;
}
示例4: build
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);
}
示例5: handle
@Override
public void handle(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
final String creds = (String) context.getAttribute("creds");
if (creds == null || !creds.equals("test:test")) {
response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
final StringEntity entity = new StringEntity("success", Consts.ASCII);
response.setEntity(entity);
}
}
示例6: testResponseParsingOnlyGarbage
@Test(expected=ProtocolException.class)
public void testResponseParsingOnlyGarbage() throws Exception {
final String s =
"garbage\r\n" +
"garbage\r\n" +
"more garbage\r\n" +
"a lot more garbage\r\n";
final SessionInputBuffer inbuffer = new SessionInputBufferMock(s, Consts.ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer);
parser.parse();
}
示例7: handle
@Override
public void handle(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
final String creds = (String) context.getAttribute("creds");
if (creds == null || !creds.equals("test:test")) {
response.setStatusCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
} else {
response.setStatusCode(HttpStatus.SC_OK);
final StringEntity entity = new StringEntity("success", Consts.ASCII);
response.setEntity(entity);
}
}
示例8: BasicSchemeHC4
public BasicSchemeHC4() {
this(Consts.ASCII);
}
示例9: DigestSchemeHC4
public DigestSchemeHC4() {
this(Consts.ASCII);
}
示例10: RFC2617SchemeHC4
/**
* @since 4.3
*/
public RFC2617SchemeHC4(final Charset credentialsCharset) {
super();
this.params = new HashMap<String, String>();
this.credentialsCharset = credentialsCharset != null ? credentialsCharset : Consts.ASCII;
}
示例11: RFC2617Scheme
/**
* @since 4.3
*/
public RFC2617Scheme(final Charset credentialsCharset) {
super();
this.params = new HashMap<String, String>();
this.credentialsCharset = credentialsCharset != null ? credentialsCharset : Consts.ASCII;
}
示例12: getCredentialsCharset
/**
* @since 4.3
*/
public Charset getCredentialsCharset() {
return credentialsCharset != null ? credentialsCharset : Consts.ASCII;
}
示例13: testResponseParsingNoResponse
@Test(expected=NoHttpResponseException.class)
public void testResponseParsingNoResponse() throws Exception {
final SessionInputBuffer inbuffer = new SessionInputBufferMock("", Consts.ASCII);
final HttpMessageParser<HttpResponse> parser = new DefaultHttpResponseParser(inbuffer);
parser.parse();
}
示例14: DigestScheme
public DigestScheme() {
this(Consts.ASCII);
}
示例15: BasicScheme
public BasicScheme() {
this(Consts.ASCII);
}