Coder Social home page Coder Social logo

Comments (4)

vaclavhodek avatar vaclavhodek commented on August 11, 2024

You have to use HttpQueryInfoW with HTTP_QUERY_COOKIE to get the corresponding header.

There's no built-in solution for handling cookies out-of-the-box. The same applies for setting cookies. You need to send Set-Cookie header manually.

from kotlin-mpp-wininet.

carlosrafp avatar carlosrafp commented on August 11, 2024

Ty, HttpQueryInfoW worked fine for me,

justed added this code in "WinInetHelper.request", after getResponseData() call

sample:
var lpszData = ByteArray(200)
val dwSize = alloc()
val index = alloc()
index.value = 0.dword()
dwSize.value = 200.dword()
lpszData.usePinned {
if (HttpQueryInfoW(requestHandle.handle,HTTP_QUERY_SET_COOKIE,it.addressOf(0),dwSize.ptr,index.ptr) == 0){
if (GetLastError().toInt() == ERROR_INSUFFICIENT_BUFFER){
println("ERROR_INSUFFICIENT_BUFFER, required_size = " + dwSize.value)
lpszData = ByteArray(dwSize.value.toInt())
index.value = 0.dword()
HttpQueryInfoW(requestHandle.handle,HTTP_QUERY_SET_COOKIE,it.addressOf(0),dwSize.ptr,index.ptr)
}
else if (GetLastError().toInt() == ERROR_HTTP_HEADER_NOT_FOUND){
index.value = 0.dword()
HttpQueryInfoW(requestHandle.handle,HTTP_QUERY_COOKIE,it.addressOf(0),dwSize.ptr,index.ptr)
println("ERROR_HTTP_HEADER_NOT_FOUND (HTTP_QUERY_SET_COOKIE) - trying HTTP_QUERY_COOKIE")
}
}
}
println("size = " + dwSize.value + ", indice = " + index.value + ", cookie = " + lpszData.decodeToString())

from kotlin-mpp-wininet.

carlosrafp avatar carlosrafp commented on August 11, 2024

Do you Know to to handle https with certificate? In java u should update sdk cacerts, no idea how to do it in klotin/native

from kotlin-mpp-wininet.

vaclavhodek avatar vaclavhodek commented on August 11, 2024

HTTPS is supported by the WinInet library and handled transparently, so the certificate has to be available in system.

It's controller by INTERNET_FLAG_SECURE flag. Check MemScope.openRequest(...) function in WinInetHelper.kt.

from kotlin-mpp-wininet.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.