本文整理汇总了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);
}