當前位置: 首頁>>代碼示例>>Java>>正文


Java CoreProtocolPNames類代碼示例

本文整理匯總了Java中org.apache.http.params.CoreProtocolPNames的典型用法代碼示例。如果您正苦於以下問題:Java CoreProtocolPNames類的具體用法?Java CoreProtocolPNames怎麽用?Java CoreProtocolPNames使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CoreProtocolPNames類屬於org.apache.http.params包,在下文中一共展示了CoreProtocolPNames類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newAsyncHttpClient

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
/**
 * 全局唯一的AsyncHttpClient對象
 * 
 * @return
 */
public static AsyncHttpClient newAsyncHttpClient()
{
	String userAgent = null;
	if (CDK.getInstance().getCDKContext() != null)
	{
		userAgent = CDK.getInstance().getCDKContext().getUserAgent();
	}
	if (userAgent == null)
	{
		userAgent = "Mozilla/5.0 (Linux; U; Android 4.3; zh-cn; GT-I9300 Build/JSS15J) "
				+ "AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.3022";
	}

	asyncHttpClient.getHttpClient().getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent + ".10");

	return asyncHttpClient;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:23,代碼來源:Wo2bAsyncHttpClient.java

示例2: QSystemHtmlInstance

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
private QSystemHtmlInstance() {
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).
        setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).
        setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).
        setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).
        setParameter(CoreProtocolPNames.ORIGIN_SERVER, "QSystemReportHttpServer/1.1");

    // Set up the HTTP protocol processor
    final BasicHttpProcessor httpproc = new BasicHttpProcessor();
    httpproc.addInterceptor(new ResponseDate());
    httpproc.addInterceptor(new ResponseServer());
    httpproc.addInterceptor(new ResponseContent());
    httpproc.addInterceptor(new ResponseConnControl());

    // Set up request handlers
    final HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpQSystemReportsHandler());

    // Set up the HTTP service
    this.httpService = new HttpService(
        httpproc,
        new DefaultConnectionReuseStrategy(),
        new DefaultHttpResponseFactory(), reqistry, this.params);
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:25,代碼來源:QSystemHtmlInstance.java

示例3: RequestListenerThread

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public RequestListenerThread(Context context) throws IOException, BindException {
	serversocket = new ServerSocket(PORT);
	params = new BasicHttpParams();
	params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
			.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
			.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

	// Set up the HTTP protocol processor
	BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
	httpProcessor.addInterceptor(new ResponseDate());
	httpProcessor.addInterceptor(new ResponseServer());
	httpProcessor.addInterceptor(new ResponseContent());
	httpProcessor.addInterceptor(new ResponseConnControl());

	// Set up the HTTP service
	this.httpService = new YaaccHttpService(httpProcessor, new DefaultConnectionReuseStrategy(), new DefaultHttpResponseFactory(), context);

}
 
開發者ID:theopenbit,項目名稱:yaacc-code,代碼行數:19,代碼來源:YaaccUpnpServerService.java

示例4: process

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public void process(final HttpRequest request, final HttpContext context)
    throws HttpException, IOException {
    Args.notNull(request, "HTTP request");
    if (!request.containsHeader(HTTP.USER_AGENT)) {
        String s = null;
        final HttpParams params = request.getParams();
        if (params != null) {
            s = (String) params.getParameter(CoreProtocolPNames.USER_AGENT);
        }
        if (s == null) {
            s = this.userAgent;
        }
        if (s != null) {
            request.addHeader(HTTP.USER_AGENT, s);
        }
    }
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:18,代碼來源:RequestUserAgentHC4.java

示例5: newAsyncHttpClient

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
/**
 * 全局唯一的AsyncHttpClient對象
 * 
 * @return
 */
public static AsyncHttpClient newAsyncHttpClient()
{
	String userAgent = null;
	if (RockySdk.getInstance().getClientInfo() != null)
	{
		userAgent = RockySdk.getInstance().getClientInfo().getUserAgent();
	}
	if (userAgent == null)
	{
		userAgent = "Mozilla/5.0 (Linux; U; Android 4.3; zh-cn; GT-I9300 Build/JSS15J) "
				+ "AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.3022";
	}

	asyncHttpClient.getHttpClient().getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent + ".10");

	return asyncHttpClient;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-wo2b,代碼行數:23,代碼來源:Wo2bAsyncHttpClient.java

示例6: postCookie

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public int postCookie(String data) throws Exception {
        HttpPost httpPost = new HttpPost(URL.toString());
        System.out.println("change user agent");
        HttpContext HTTP_CONTEXT = new BasicHttpContext();
        client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13");

        HTTP_CONTEXT.setAttribute(CoreProtocolPNames.USER_AGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13");
        httpPost.setHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13");

        if (isAuthByPrivateKey) httpPost.setHeaders(headersArray);
//        httpPost.addHeader("Content-Type","application/json")
//        httpPost.addHeader("host",this.host)
        log.debug("Post send :" + data.replace("\n", ""));
        //write data
        BasicHttpEntity entity = new BasicHttpEntity();
        entity.setContent(new ByteArrayInputStream(data.getBytes()));
        entity.setContentLength((long)data.getBytes().length);
        httpPost.setEntity(entity);
        response = client.execute(targetHost, httpPost, localcontext);
        return response.getStatusLine().getStatusCode();
    }
 
開發者ID:cytomine,項目名稱:Cytomine-client-autobuilder,代碼行數:22,代碼來源:HttpClient.java

示例7: RequestListenerThread

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public RequestListenerThread(int port, final String docroot) throws IOException {
    this.serversocket = new ServerSocket(port);
    this.params = new SyncBasicHttpParams();
    this.params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "HttpComponents/1.1");

    // Set up the HTTP protocol processor
    HttpProcessor httpproc = new ImmutableHttpProcessor(new HttpResponseInterceptor[]{
        new ResponseDate(),
        new ResponseServer(),
        new ResponseContent(),
        new ResponseConnControl()
    });

    // Set up request handlers
    HttpRequestHandlerRegistry reqistry = new HttpRequestHandlerRegistry();
    reqistry.register("*", new HttpFileHandler());

    // Set up the HTTP service
    this.httpService = new HttpService(
            httpproc,
            new DefaultConnectionReuseStrategy(),
            new DefaultHttpResponseFactory(),
            reqistry,
            this.params);
}
 
開發者ID:Torridity,項目名稱:dsworkbench,代碼行數:26,代碼來源:ReportServer.java

示例8: get_url_contents

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
String get_url_contents( String url , List<NameValuePair> params , CookieStore cookieStore ) {
    try {
        HttpClient client = MySSLSocketFactory.createMyHttpClient();
        client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT);
        HttpResponse response = null;
        if( cookieStore == null )
            response = client.execute( new HttpGet( params == null || params.size() == 0 ? url : url + "?" + URLEncodedUtils.format(params, "utf-8") ) );
        else {
            HttpContext mHttpContext = new BasicHttpContext();
            mHttpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
            response = client.execute( new HttpGet( params == null || params.size() == 0 ? url : url + "?" + URLEncodedUtils.format(params, "utf-8") ) , mHttpContext );
        }
        HttpEntity result = response.getEntity();
        if( result != null ) {
            InputStream mInputStream = result.getContent();
            String out = getStringFromInputStream(mInputStream);
            mInputStream.close();
            return out;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}
 
開發者ID:hearsilent,項目名稱:XiaomiOrder,代碼行數:25,代碼來源:MainActivity.java

示例9: getRequestParams

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
protected HttpParams getRequestParams(StreamRequestMessage requestMessage) {
    HttpParams localParams = new BasicHttpParams();

    localParams.setParameter(
            CoreProtocolPNames.PROTOCOL_VERSION,
            requestMessage.getOperation().getHttpMinorVersion() == 0 ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1
    );

    // DefaultHttpClient adds HOST header automatically in its default processor

    // Let's add the user-agent header on every request
    HttpProtocolParams.setUserAgent(
            localParams,
            getConfiguration().getUserAgentValue(requestMessage.getUdaMajorVersion(), requestMessage.getUdaMinorVersion())
    );

    return new DefaultedHttpParams(localParams, globalParams);
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:19,代碼來源:StreamClientImpl.java

示例10: getDefaultHttpClient

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
/** 
 * 獲取DefaultHttpClient對象 
 *  
 * @param charset 
 *            字符編碼 
 * @return DefaultHttpClient對象 
 */  
private static DefaultHttpClient getDefaultHttpClient(final String charset) {  
    DefaultHttpClient httpclient = new DefaultHttpClient();  
    // 模擬瀏覽器,解決一些服務器程序隻允許瀏覽器訪問的問題  
    httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,  
            USER_AGENT);  
    httpclient.getParams().setParameter(  
            CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);  
    httpclient.getParams().setParameter(  
            CoreProtocolPNames.HTTP_CONTENT_CHARSET,  
            charset == null ? CHARSET_ENCODING : charset);  
      
    // 瀏覽器兼容性  
    httpclient.getParams().setParameter(ClientPNames.COOKIE_POLICY,  
            CookiePolicy.BROWSER_COMPATIBILITY);  
    // 定義重試策略  
    httpclient.setHttpRequestRetryHandler(requestRetryHandler);  
      
    return httpclient;  
}
 
開發者ID:hoozheng,項目名稱:AndroidRobot,代碼行數:27,代碼來源:HttpClientUtil.java

示例11: getRequestParams

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
protected HttpParams getRequestParams(StreamRequestMessage requestMessage) {
    HttpParams localParams = new BasicHttpParams();

    localParams.setParameter(
        CoreProtocolPNames.PROTOCOL_VERSION,
        requestMessage.getOperation().getHttpMinorVersion() == 0 ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1
    );

    // DefaultHttpClient adds HOST header automatically in its default processor

    // Add the default user agent if not already set on the message
    if (!requestMessage.getHeaders().containsKey(UpnpHeader.Type.USER_AGENT)) {
        HttpProtocolParams.setUserAgent(
            localParams,
            getConfiguration().getUserAgentValue(requestMessage.getUdaMajorVersion(), requestMessage.getUdaMinorVersion())
        );
    }

    return new DefaultedHttpParams(localParams, globalParams);
}
 
開發者ID:offbye,項目名稱:DroidDLNA,代碼行數:21,代碼來源:StreamClientImpl.java

示例12: fileUpload

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public static void fileUpload() throws IOException {
    HttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    HttpPost httppost = new HttpPost(postURL);
    File file = new File("d:/hai.html");
    System.out.println(ukeycookie);
    httppost.setHeader("Cookie", ukeycookie + ";" + skeycookie + ";" + usercookie);
    MultipartEntity mpEntity = new MultipartEntity();
    ContentBody cbFile = new FileBody(file);
    mpEntity.addPart("", cbFile);
    httppost.setEntity(mpEntity);
    System.out.println("Now uploading your file into mediafire...........................");
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();

    System.out.println(response.getStatusLine());
    if (resEntity != null) {
        System.out.println("Getting upload response key value..........");
        uploadresponsekey = EntityUtils.toString(resEntity);
        getUploadResponseKey();
        System.out.println("upload resoponse key " + uploadresponsekey);
    }
}
 
開發者ID:Neembuu-Uploader,項目名稱:neembuu-uploader,代碼行數:24,代碼來源:MediaFireUploadPlugin.java

示例13: fileUpload

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public static void fileUpload() throws IOException {
    HttpClient httpclient = new DefaultHttpClient();
    httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    file = new File("/home/vigneshwaran/dinesh.txt");
    HttpPost httppost = new HttpPost(postURL);
    httppost.setHeader("Cookie", langcookie + ";" + sessioncookie + ";" + mailcookie + ";" + namecookie + ";" + rolecookie + ";" + orderbycookie + ";" + directioncookie + ";");
    MultipartEntity mpEntity = new MultipartEntity();
    ContentBody cbFile = new FileBody(file);
    mpEntity.addPart("files[]", cbFile);
    httppost.setEntity(mpEntity);
    System.out.println("Now uploading your file into wupload...........................");
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity resEntity = response.getEntity();
    System.out.println(response.getStatusLine());
    if (response.getStatusLine().getStatusCode() == 302
            && response.getFirstHeader("Location").getValue().contains("upload/done/")) {

        System.out.println("Upload successful :)");
    } else {
        System.out.println("Upload failed :(");
    }

}
 
開發者ID:Neembuu-Uploader,項目名稱:neembuu-uploader,代碼行數:24,代碼來源:WuploadUploaderPlugin.java

示例14: fileUpload

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
public static void fileUpload() throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        file = new File("C:\\Documents and Settings\\dinesh\\Desktop\\GeDotttUploaderPlugin.java");
        HttpPost httppost = new HttpPost("https://docs.zoho.com/uploadsingle.do?isUploadStatus=false&folderId=0&refFileElementId=refFileElement0");
        httppost.setHeader("Cookie", cookies.toString());
        MultipartEntity mpEntity = new MultipartEntity();
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("multiupload_file", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("Now uploading your file into zoho docs...........................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());
        if (resEntity != null) {

            String tmp = EntityUtils.toString(resEntity);
//            System.out.println(tmp);
            if(tmp.contains("File Uploaded Successfully"))
                System.out.println("File Uploaded Successfully");

        }
        //    uploadresponse = response.getLastHeader("Location").getValue();
        //  System.out.println("Upload response : " + uploadresponse);
    }
 
開發者ID:Neembuu-Uploader,項目名稱:neembuu-uploader,代碼行數:26,代碼來源:ZohoDocsUploaderPlugin.java

示例15: HttpServer

import org.apache.http.params.CoreProtocolPNames; //導入依賴的package包/類
private HttpServer(WifiManager wifiManager) {
	this.wifiManager = wifiManager;
	this.listenPort = 0;

	this.handlerRegistry = new HttpRequestHandlerRegistry();

	this.params = new BasicHttpParams();
	this.params
			.setParameter(CoreProtocolPNames.ORIGIN_SERVER,
					"4thLineAndroidHttpServer/1.0")
			.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
			.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,
					8 * 1024)
			.setBooleanParameter(
					CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
			.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);

	startServer();
}
 
開發者ID:jasoncn90,項目名稱:dlna-for-android,代碼行數:20,代碼來源:HttpServer.java


注:本文中的org.apache.http.params.CoreProtocolPNames類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。