Someone asked this question a few years ago, but no one answered
Working in Titanium SDK 3.1.3.GA, when i created a HTTPClient, the autoRedirect: false
parameter does not work. The request gets auto-redirected, & i cannot access the headers of the original 302 request.
Controller
function go() { var xhr = Ti.Network.createHTTPClient({ autoRedirect: false, onload: function(e) { var allCookies = xhr.getResponseHeader("Set-Cookie"), mycookie = getCookie("mycookie", allCookies); Ti.UI.createAlertDialog({ message: mycookie || "No cookie..." }).show(); }, onerror: function(e) { Ti.API.error(e.error); } }); xhr.open("POST", String.format("%s/form", Alloy.CFG.server)); xhr.send(); } function getCookie(key, allCookies) { var result; return ( result = new RegExp("(?:^|; )" + encodeURIComponent(key) + "=(^;*)").exec(allCookies) ) ? result[1] : null; } $.index.open();Express Server
var express = require("express"); var params = { port: process.env.PORT || 3000 }; var app = express(); app.post("/form", function(req, res) { res.cookie("mycookie", "I got a cookie!"); res.redirect("/dest"); }); app.get("/dest", function(req, res) { res.send({ msg: "Success!" }); }); app.listen(params.port, function() { console.log("Listening on port " + params.port); });Wireshark Trace
Thank you for your time.