Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make an array of org.apache.http.Header?

I'm new in Java.

I'm trying to do

import org.apache.http.Header;
Header<NameValuePair> nvps = new HeaderList<NameValuePair>();
//....adding some headers
httppost.setHeaders(nvps);

but said

The type Header is not generic; it cannot be parameterized with arguments <NameValuePair>

how I can do it?

like image 666
user383343 Avatar asked Aug 11 '10 03:08

user383343


1 Answers

I found the answer

Header[] headers = {
    new BasicHeader("Content-type", "application/x-www-form-urlencoded")
    ,new BasicHeader("Content-type", "application/x-www-form-urlencoded")
    ,new BasicHeader("Accep", "text/html,text/xml,application/xml")
    ,new BasicHeader("Connection", "keep-alive")
    ,new BasicHeader("keep-alive", "115")
    ,new BasicHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2")
};
like image 167
user383343 Avatar answered Oct 06 '22 01:10

user383343