login about faq

Hi!

I have trouble downloading a binary from a https server with basic http auth. I cannot find the error in LastError.txt. I can use the same credentials and URL with a browser and if I change my code to download from a http instead of a https server and remove the basic auth (not required for the URL I tested), the code is working fine.

It's obvious from LastError.txt that there's a 401 Unauthorized. But I set the correct Username and Password.

BTW: Looking at some other (working) Chilkathttp based https requests to the same server (which are not downloading binary files), I think I must have overseen some option to tell Chilkathttp to immediately provide http auth information rather than first trying without and then retrying after a 401 was received. Looking at LastErrorTXT from those requests I think that there's always a request without http auth information and only after the 401 an additional request including the http basic auth information is being sent.

This is the code I use, it's based on this example:

Option Explicit

Dim WithEvents http As ChilkatHttp
Dim bAbort As Boolean

Private Sub AbortBtn_Click()
    bAbort = True
End Sub

Private Sub Command1_Click()
Dim success As Long

Set http = New ChilkatHttp

'  Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    MsgBox http.LastErrorText
    Exit Sub
End If

http.HeartbeatMs = 100
http.login = "Username"
http.Password = "TheRightPassword"

ProgressBar1.value = 0
bAbort = False
AbortBtn.SetFocus

success = http.Download("https://www.domain.com/downloads/TheFile.exe", "c:\temp\foo.exe")

If (success <> 1) Then
    Debug.Print http.LastErrorText
    MsgBox "Error downloading"
Else
    Debug.Print "Download in progress"
End If   
End Sub

Private Sub http_AbortCheck(abort As Long)
    If (bAbort) Then abort = 1
    DoEvents
End Sub

Private Sub http_EndReceive(ByVal success As Long)
    Debug.Print "download completed"
End Sub

Private Sub http_PercentDone(ByVal percent As Long, abort As Long)
    ProgressBar1.value = percent
End Sub

This is LastError.txt:

download completed
ChilkatLog:
  Download:
    DllDate: Jun 23 2015
    ChilkatVersion: 9.5.0.51
    UnlockPrefix: Anything for 30-day trial
    Username: MyHostName:MyUserName
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    url: https://www.domain.com/downloads/TheFile.exe
    toLocalPath: c:tempfoo.exe
    currentWorkingDir: C:temp1
    a_httpDownload:
      httpDownloadFile:
        localFilePath: c:tempfoo.exe
        localFileAlreadyExists: 0
        quickHttpRequest:
          httpVerb: GET
          url: https://www.domain.com/downloads/TheFile.exe
          openHttpConnection:
            Opening connection directly to HTTP server.
            httpHostname: www.domain.com
            httpPort: 443
            ssl: 1
            HTTPS secure channel established.
          --openHttpConnection
          buildQuickRequest:
            genStartLine:
              startLine: GET /downloads/TheFile.exe HTTP/1.1
            --genStartLine
            addCookies:
              Not auto-adding cookies.
              sendCookies: 1
              cookieDir: 
            --addCookies
          --buildQuickRequest
          sendRequestHeader:
            sendHeaderElapsedMs: 16
          --sendRequestHeader
          statusCode: 401
          statusText: Unauthorized
          readResponseBody:
            contentLength: 364
          --readResponseBody
          checkCloseConnection:
            Response includes connection:close header (or proxy-connection:close header)
          --checkCloseConnection
        --quickHttpRequest
      --httpDownloadFile
    --a_httpDownload
    totalElapsedMs: 360
    ContentLength: 364
    Failed.
  --Download
--ChilkatLog

asked Jul 27 '15 at 15:51

torsten's gravatar image

torsten
11

Could anyone please test Chilkathttp.download on a https site with basic auth? I tested some more and to me it looks like there's a bug in Chilkathttp.

(Jul 29 '15 at 05:41) torsten

I'll test as soon as possible, but Chilkat is working on some internal code refactoring for the support of ECC, and it will be a day or two before things are back in order..

(Jul 29 '15 at 09:55) chilkat ♦♦

Got a solution from Chilkat:

Default behaviour will probably be changed in a future version but for now it's sufficient to just add

http.BasicAuth = 1

Verified.

T.

link

answered Aug 04 '15 at 05:47

torsten's gravatar image

torsten
11

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×35
×33
×13
×2

Asked: Jul 27 '15 at 15:51

Seen: 890 times

Last updated: Aug 04 '15 at 05:47

powered by OSQA