Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8998629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:03:46+00:00 2026-06-16T00:03:46+00:00

I have a little crazy problem. I have an IIS7 where I need to

  • 0

I have a little crazy problem. I have an IIS7 where I need to post a formular via POST, also I need to authenticate via NTLM and all this stuff thrue a SSL connection. So far I managed it to connect to the server and post my data.

After the POST I’ll get on success a 302 response which redirects me to a second page. The DefaultHttpClient connects to the webserver does the auth and post the data. So far everything works. But now the client closes the connection and opens a second connection (this behavoir is anying me) but this is not my problem. On the second connection the client forget how to auth on the IIS and breaks with the 401 auth error.

So far I can see this is a fixed bug in the source of DefaultHttpClient, but Android seems to use an older version of this lib. How can I fix that bug which seems to be on every android device on the world?

Here are the relevant parts of my communication:

POST /login/ HTTP/1.1
Content-Length: 21
Content-Type: application/x-www-form-urlencoded
Host: example.com
Connection: Keep-Alive
Cookie: ASPSESSION...

[the post data]

HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/7.5
WWW-Authenticate: NTLM
Content-Length: 1344

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
...
</html>

POST /login/ HTTP/1.1
Content-Length: 21
Content-Type: application/x-www-form-urlencoded
Host: example.com
Connection: Keep-Alive
Cookie: ASPSESSION...
Authorization: NTLM ABC...==

[the post data]

HTTP/1.1 401 Unauthorized
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
WWW-Authenticate: NTLM ABC...DEF
Content-Length: 341

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Authorized</TITLE>...</HTML>

POST /login/ HTTP/1.1
Content-Length: 21
Content-Type: application/x-www-form-urlencoded
Host: example.com
Connection: Keep-Alive
Cookie: ASPSESSION...
Authorization: NTLM ABC...DEF

[the post data]

HTTP/1.1 302 Moved Temporary
Cache-Control: private,no-cache
Pragma: no-cache
Content-Length: 31
Content-Type: application/json; Charset=UTF-8
Expires: Fri, 07 Dec 2012 07:01:00 GMT
Location: /login/step2.asp
Server: Microsoft-IIS/7.5
Set-Cookie: [...] path=/login/; HttpOnly;
Persistent-Auth: true

[some response]

— now does the connetion close and a second https connection is opened —

GET /login/step2.asp HTTP/1.1
Host: example.com
Connection: Keep-Alive
Cookie: ASPSESSION...


HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/7.5
WWW-Authenticate: NTLM
Content-Length: 1344

— and the connection closes again —

Does you know a way to fix that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:03:47+00:00Added an answer on June 16, 2026 at 12:03 am

    Well this is no solution just a workaround for my problem, but this may help. I override the createClientRequestDirector function in the DefaultHttpClient where I handle the redirect by my own.

    The cause for the connection closing is that I play with the host names, so I connect to the IP and not the host name. The result is that the client looks while redirection if the connection can be reused by comparing the source and destination url. So it will be compaired https://www.example.com/ with https://127.0.0.1/ which failes and the conenction will be closed.

    My solution is that I check this part by my own. And if the hostname and IP matches I’ll return the last used IP. The result is that the connection can be reused and I don’t run in the bug linked above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little unusual problem to solve. I need some hint or links to
This problem is making me crazy. Actually I have multiple problems. First one: Why
I have a little problem..but im goin' to crazy... In the html i have
I'm starting to go a little crazy with this one. I have an iphone
I have this little crazy method that converts BigDecimal values into nice and readable
ok this may sound a little crazy but, i have class A and a
I have little question about how web browser retrieve webpage? I know this User
I have little snippet for validatin' my form. I need help to position the
I have little problem with a replacement of a little part in an url.
I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.