Archived Forum Post

Index of archived forum posts

Question:

User Agent String seems to not be sent in http(request/response) yet http.QuickGetStr works fine!

Jan 21 '17 at 19:22

Code Scrap: Dim request As New ChilkatHttpRequest Dim http As New ChilkatHttp Dim response As ChilkatHttpResponse success = http.UnlockComponent("Super_Secret") If Not (success = 1) Then 'Crash and Burn here Exit Sub End If request.AddParam "Size", "1" request.AddParam "page", "2" request.AddParam "Name", "Randy" request.AddParam "Code", "ABC" Set response = http.PostUrlEncoded("http://ragsoftinc.com/dev/index.php", request) //just Safely displays POST and GET vars

strhtml = response.BodyStr

so I get an error HTTP/1.1 400 Bad Request from openresty I'm told due to not sending a UA? html response and LastErrorText also session log

<head><title>400 Bad Request</title></head>

<body bgcolor="white">

400 Bad Request


openresty/1.11.2.2

</body> </html>

******ChilkatLog: PostUrlEncoded: DllDate: Dec 27 2016 ChilkatVersion: 9.5.0.65 UnlockPrefix: RAGSOFHttp Architecture: Little Endian; 32-bit Language: ActiveX VerboseLogging: 0 url: http://ragsoftinc.com/dev/index.php httpRequest: httpVersion: 1.1 verb: GET path: / contentType: charset: windows-1252 sendCharset: 0 mimeHeader: requestParams: requestItem: name: Size value: 1 --requestItem requestItem: name: page value: 2 --requestItem requestItem: name: Name value: Randy --requestItem requestItem: name: Code value: ABC --requestItem --requestParams --httpRequest fullRequest: a_synchronousRequest: generateRequestHeader: httpRequestGenStartLine: genStartLine: startLine: POST /dev/index.php HTTP/1.1 --genStartLine --httpRequestGenStartLine addCookies: Not auto-adding cookies. sendCookies: 1 cookieDir: --addCookies --generateRequestHeader fullHttpRequest: domain: ragsoftinc.com port: 80 ssl: 0 openHttpConnection: Opening connection directly to HTTP server. httpHostname: ragsoftinc.com httpPort: 80 ssl: 0 HTTP connection succeeded. --openHttpConnection connectTime: Elapsed time: 93 millisec sendRequestHeader: sendHeaderElapsedMs: 0 --sendRequestHeader sendRequestBody: sendBodyElapsedMs: 0 --sendRequestBody statusCode: 400 statusText: Bad Request checkCloseConnection: Response includes connection:close header (or proxy-connection:close header) --checkCloseConnection --fullHttpRequest success: 1 --a_synchronousRequest success: 1 --fullRequest Success. --PostUrlEncoded urlObject_loadUrl: --urlObject_loadUrl --ChilkatLog

SESSION LOG

---- Sending ---- POST /dev/index.php HTTP/1.1 Content-Type: application/x-www-form-urlencoded Host: ragsoftinc.com Content-Length: 33

Size=1&page=2&Name=Randy&Code=ABC

HTTP/1.1 400 Bad Request Server: openresty/1.11.2.2 Date: Wed, 18 Jan 2017 20:27:09 GMT Content-Type: text/html Content-Length: 179 Connection: close

<html> <head><title>400 Bad Request</title></head> <body bgcolor="white">

400 Bad Request


openresty/1.11.2.2
</body> </html>


Answer

Wow, I do not know how I missed the request.AddHeader method!

request.AddHeader "User-Agent", "what ever UA string you want" 

I kinda thought there would be a default as there are in other classes.

anyway solved my own issue, thanks