hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Troccola (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-1064) ExecutionContext returning HttpUriRequest with invalid URI (missing host)
Date Sun, 06 Mar 2011 09:13:46 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13003118#comment-13003118
] 

Ted Troccola commented on HTTPCLIENT-1064:
------------------------------------------

Oleg,

Any idea why the following code doesn't follow the 302 automatically?

---
public static void main(String[] args) throws ClientProtocolException,
IOException
 {

// TODO: Delete after fixing problem in main_BUG()

 String url = "http://www.wc3c.net/register.php";

HttpParams httpParams = new BasicHttpParams();
 HttpClient httpclient = new DefaultHttpClient(httpParams);
HttpPost httpPost = new HttpPost(url);

httpPost.addHeader(HttpHeaders.ACCEPT,
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

 List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
nameValuePairList.add(new BasicNameValuePair("s", ""));
 nameValuePairList.add(new BasicNameValuePair("do", "addmember"));
nameValuePairList.add(new BasicNameValuePair("url", "http%3A%2F%
2Fwww.wc3c.net%2Findex.php"));
 nameValuePairList.add(new BasicNameValuePair("agree", "1"));
nameValuePairList.add(new BasicNameValuePair("password_md5", ""));
 nameValuePairList.add(new BasicNameValuePair("passwordconfirm_md5", ""));
nameValuePairList.add(new BasicNameValuePair("day", "0"));
 nameValuePairList.add(new BasicNameValuePair("month", "0"));
nameValuePairList.add(new BasicNameValuePair("year", "0"));
 nameValuePairList.add(new BasicNameValuePair("username", "edisonar"));
nameValuePairList.add(new BasicNameValuePair("password", "TselHhW"));
 nameValuePairList.add(new BasicNameValuePair("passwordconfirm",
"TselHhW"));
nameValuePairList.add(new BasicNameValuePair("email", "aduazs@vmekrgiw.com
"));
 nameValuePairList.add(new BasicNameValuePair("emailconfirm", "
aduazs@vmekrgiw.com"));
 nameValuePairList.add(new BasicNameValuePair("timezoneoffset", "-7"));
nameValuePairList.add(new BasicNameValuePair("dst", "1"));
 nameValuePairList.add(new BasicNameValuePair("options[adminemail]", "1"));
nameValuePairList.add(new BasicNameValuePair("options[showemail]", "1"));
 nameValuePairList.add(new BasicNameValuePair("imabot", "Yes"));

HttpEntity paramsEntity = new UrlEncodedFormEntity(nameValuePairList,
HTTP.UTF_8);

httpPost.setEntity(paramsEntity);

HttpContext context = new BasicHttpContext();
 HttpResponse response = httpclient.execute(httpPost, context);

if ((response.getStatusLine().getStatusCode() ==
HttpStatus.SC_MOVED_TEMPORARILY))
 {
System.out.println("Why is this redirect not handled?");
}
 }
---

Thanks!!!




> ExecutionContext returning HttpUriRequest with invalid URI (missing host)
> -------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1064
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1064
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.1 Final
>         Environment: Windows 7, java 1.6.0.21
>            Reporter: Ted Troccola
>              Labels: HttpClient
>
> The HttpUriRequest contains an invalid URI - host is null
> public static void main(String args[]) throws ClientProtocolException, IOException
> {
>     HttpParams httpParams = new BasicHttpParams();
>     HttpClient httpclient = new DefaultHttpClient(httpParams);
>     HttpGet httpGet = new HttpGet("http://www.google.com/");
>     HttpContext context = new BasicHttpContext();
>     httpclient.execute(httpGet, context);
>     HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
>     System.out.println("New URI host (why is it null?): " + currentReq.getURI().getHost());
> }

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message