how to pass cookies in winnovative - cookies

first of all I would like to wish everyone a happy 2015 and be prosperous for all of you.
I would like to help me with a problem I have with a cookie and Winnovative, the problem is that I correctly the data in a cookie but when the process for the dll and reaches the window that gets data to the cookie comes in white with no data. not then I'm doing wrong. Annex code to Confinued:
string apo = String.Empty;
apo = Request.Cookies["dApoderados"].Value;
HttpCookie datosApoderados = new HttpCookie("datosApoderados");
string cadenaPDF = String.Empty;
string ruta = String.Empty;
ruta = ObtenerDireccionInformeSalida();
ruta = ruta.Replace("../", "");
GenerarQueryString();
Response.Cookies["datosApoderados"].Value = apo;
ruta = "http://localhost:10458/" + ruta;
byte[] bytes = ObtenerPdfBytes(ruta);
That's when I want to process, then passes through an intermediate product which is:
public byte[] ObtenerPdfBytes(string ruta)
{
string datosClientes = Request.Cookies["datosCliente"].Value;
string datosApoderados = Request.Cookies["datosApoderados"].Value;
datosClientes = "?DATOS=" + datosClientes;
ruta = ruta + datosClientes;
PdfConverter pdfConverter = new PdfConverter();
HttpCookie prueba = new HttpCookie("prueba");
Response.Cookies["prueba"].Value = datosApoderados;
if (Context.Request.Cookies[FormsAuthentication.FormsCookieName] != null)
{
pdfConverter.HttpRequestHeaders = String.Format("prueba : {0}={1}",
FormsAuthentication.FormsCookieName, Request.Cookies[FormsAuthentication.FormsCookieName].Value);
}
pdfConverter.LicenseKey = ClaveGeneradorPdf;
pdfConverter.PdfDocumentOptions.ShowFooter = true;
pdfConverter.PdfFooterOptions.PageNumberText = TextoPagina;
pdfConverter.PdfFooterOptions.PageNumberTextFontType = PdfFontType.HelveticaBold;
pdfConverter.PdfFooterOptions.PageNumberTextFontSize = 8;
pdfConverter.PdfFooterOptions.ShowPageNumber = true;
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.Legal;
pdfConverter.PdfFooterOptions.FooterHeight = AltoPie;
pdfConverter.PdfDocumentOptions.LeftMargin = MargenIzquierdo;
pdfConverter.PdfDocumentOptions.RightMargin = MargenDerecho;
pdfConverter.PdfDocumentOptions.TopMargin = MargenSuperior;
pdfConverter.PdfDocumentOptions.BottomMargin = MargenInferior;
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
pdfConverter.PdfFooterOptions.FooterText = "texto";
pdfConverter.PdfFooterOptions.FooterTextFontType = PdfFontType.HelveticaBold;
pdfConverter.PdfFooterOptions.FooterTextFontSize = 8;
pdfConverter.PdfDocumentOptions.ShowHeader = false;
byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(ruta);
return pdfBytes;
}
when I get to the next line is where the cookie is lost:
byte [] pdfBytes = pdfConverter.GetPdfBytesFromUrl (path);
public override void Pagina_PrimeraCarga(object sender, EventArgs e)
{
string prueba = Request.Cookies["prueba"].Value;
string datosRequest = Request.QueryString["DATOS"];
char delimitadores = ';';
string[] datos = datosRequest.Split(delimitadores);
imgBanco.Attributes.Add("ImageUrl", "~/App_Themes/Imagenes/Logo.gif");
DateTime fechaHoy = DateTime.Now;
lblDia.Text = Convert.ToString(fechaHoy.Day);
lblMes.Text = Convert.ToString(fechaHoy.Month);
lblAno.Text = Convert.ToString(fechaHoy.Year);
loading data from the cookie in the latter code:
string test = Request.Cookies ["test"] Value.;
This goes empty and no data

The converter has a HttpRequestCookies collection you can use. There is a complete example for cookies in Winnovative website. Here is the relevant code copied from there:
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Set license key received after purchase to use the converter in licensed mode
// Leave it not set to use the converter in demo mode
htmlToPdfConverter.LicenseKey = "fvDh8eDx4fHg4P/h8eLg/+Dj/+jo6Og=";
// Add custom HTTP cookies
if (cookie1NameTextBox.Text.Length > 0 && cookie1ValueTextBox.Text.Length > 0)
htmlToPdfConverter.HttpRequestCookies.Add(cookie1NameTextBox.Text, cookie1ValueTextBox.Text);
if (cookie2NameTextBox.Text.Length > 0 && cookie2ValueTextBox.Text.Length > 0)
htmlToPdfConverter.HttpRequestCookies.Add(cookie2NameTextBox.Text, cookie2ValueTextBox.Text);
if (cookie3NameTextBox.Text.Length > 0 && cookie3ValueTextBox.Text.Length > 0)
htmlToPdfConverter.HttpRequestCookies.Add(cookie3NameTextBox.Text, cookie3ValueTextBox.Text);
if (cookie4NameTextBox.Text.Length > 0 && cookie4ValueTextBox.Text.Length > 0)
htmlToPdfConverter.HttpRequestCookies.Add(cookie4NameTextBox.Text, cookie4ValueTextBox.Text);
if (cookie5NameTextBox.Text.Length > 0 && cookie5ValueTextBox.Text.Length > 0)
htmlToPdfConverter.HttpRequestCookies.Add(cookie5NameTextBox.Text, cookie5ValueTextBox.Text);
// Convert the HTML page to a PDF document in a memory buffer
byte[] outPdfBuffer = htmlToPdfConverter.ConvertUrl(urlTextBox.Text);
// Send the PDF as response to browser
// Set response content type
Response.AddHeader("Content-Type", "application/pdf");
// Instruct the browser to open the PDF file as an attachment or inline
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=HTTP_Cookies.pdf; size={0}", outPdfBuffer.Length.ToString()));
// Write the PDF document buffer to HTTP response
Response.BinaryWrite(outPdfBuffer);
// End the HTTP response and stop the current page processing
Response.End();

Related

Getting EntityTooSmall Exception

I am trying to download data from Azure blob in chunk and then trying to upload same chunk to aws s3 bucket.
While uploading I am getting "Your proposed upload is smaller than the minimum allowed size"exception. One thing I noticed, in upload response I am getting 0 content length. Data size I am trying is more than 300MB.
Any pointers what could be wrong here?
Below is my code snippet :
var remainingLength = blob.Properties.Length;
long startPosition = 0;
List<UploadPartResponse> uploadResponses = new List<UploadPartResponse>();
int i = 1;
string uploadId = string.Empty;
//Step 1: build and send a multi upload request
var initiateRequest = new InitiateMultipartUploadRequest
{
BucketName = existingBucketName,
Key = "firstobj"
};
var initResponse = client.InitiateMultipartUpload(initiateRequest);
uploadId = initResponse.UploadId;
do
{
var blockSize = Math.Min(segmentSize, remainingLength);
using (var ms = new MemoryStream())
{
blob.DownloadRangeToStream(ms, startPosition, blockSize);
//Step 2: upload each chunk (this is run for every chunk unlike the other steps which are run once)
var uploadRequest = new UploadPartRequest
{
BucketName = existingBucketName,
Key = "firstobj",
UploadId = uploadId,
PartNumber = i,
PartSize = ms.Length,
InputStream = ms
};
// Upload part and add response to our list.
var temp = client.UploadPart(uploadRequest);
uploadResponses.Add(temp);
}
//Step 3: build and send the multipart complete request
if (blockSize < segmentSize)
{
var completeRequest = new CompleteMultipartUploadRequest
{
BucketName = existingBucketName,
Key = "firstobj",
UploadId = uploadId,
};
completeRequest.AddPartETags(uploadResponses);
client.CompleteMultipartUpload(completeRequest);
}
startPosition += blockSize;
remainingLength -= blockSize;
i++;
}
while (remainingLength > 0);
After banging my head a lot, I got solution for this. It was in step 2 just before uploading part to AWS we should set stream position to 0.
uploadRequest.InputStream.Position = 0;

Authentication Error (Authentication Failed) Using Sabre Soap Message

I am using soap service to authenticate request by sabre as in the document https://developer.sabre.com/docs/read/soap_basics/Authentication.
I generate the proxy classes using wsdl. i put authentication credential in the code. This is my Code for test purpose:
using ConsoleApplication1.SessionReference1;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
[STAThread]
static void Main(string[] args)
{
try
{
// Set user information, including security credentials and the IPCC.
string username = "my-username";
string password = "my-password";
string ipcc = "not-understand";
string domain = "EXT";
string temp = Environment.GetEnvironmentVariable("tmp"); // Get temp directory
string PropsFileName = temp + "/session.properties"; // Define dir and file name
DateTime dt = DateTime.UtcNow;
string tstamp = dt.ToString("s") + "Z";
//Create the message header and provide the conversation ID.
MessageHeader msgHeader = new MessageHeader();
msgHeader.ConversationId = "TestSession"; // Set the ConversationId
From from = new From();
PartyId fromPartyId = new PartyId();
PartyId[] fromPartyIdArr = new PartyId[1];
fromPartyId.Value = "WebServiceClient";
fromPartyIdArr[0] = fromPartyId;
from.PartyId = fromPartyIdArr;
msgHeader.From = from;
To to = new To();
PartyId toPartyId = new PartyId();
PartyId[] toPartyIdArr = new PartyId[1];
toPartyId.Value = "WebServiceSupplier";
toPartyIdArr[0] = toPartyId;
to.PartyId = toPartyIdArr;
msgHeader.To = to;
//Add the value for eb:CPAId, which is the IPCC.
//Add the value for the action code of this Web service, SessionCreateRQ.
msgHeader.CPAId = ipcc;
msgHeader.Action = "SessionCreateRQ";
Service service = new Service();
service.Value = "SessionCreate";
msgHeader.Service = service;
MessageData msgData = new MessageData();
msgData.MessageId = "mid:20001209-133003-2333#clientofsabre.com1";
msgData.Timestamp = tstamp;
msgHeader.MessageData = msgData;
Security security = new Security();
SecurityUsernameToken securityUserToken = new SecurityUsernameToken();
securityUserToken.Username = username;
securityUserToken.Password = password;
securityUserToken.Organization = ipcc;
securityUserToken.Domain = domain;
security.UsernameToken = securityUserToken;
SessionCreateRQ req = new SessionCreateRQ();
SessionCreateRQPOS pos = new SessionCreateRQPOS();
SessionCreateRQPOSSource source = new SessionCreateRQPOSSource();
source.PseudoCityCode = ipcc;
pos.Source = source;
req.POS = pos;
SessionCreatePortTypeClient s = new SessionCreatePortTypeClient();
SessionCreateRS resp = s.SessionCreateRQ(ref msgHeader, ref security, req);
//SessionCreateRQService serviceObj = new SessionCreateRQService();
//serviceObj.MessageHeaderValue = msgHeader;
//serviceObj.SecurityValue = security;
//SessionCreateRS rs = new SessionCreateRS();
//SessionCreateRS = serviceObj.SessionCreateRQ(req); // Send the request
if (resp.Errors != null && resp.Errors.Error != null)
{
Console.WriteLine("Error : " + resp.Errors.Error.ErrorInfo.Message);
}
else
{
// msgHeader = serviceObj.MessageHeaderValue;
// security = serviceObj.SecurityValue;
Console.WriteLine("**********************************************");
Console.WriteLine("Response of SessionCreateRQ service");
Console.WriteLine("BinarySecurityToken returned : " + security.BinarySecurityToken);
Console.WriteLine("**********************************************");
string ConvIdLine = "convid=" + msgHeader.ConversationId; // ConversationId to a string
string TokenLine = "securitytoken=" + security.BinarySecurityToken; // BinarySecurityToken to a string
string ipccLine = "ipcc=" + ipcc; // IPCC to a string
// File.Delete(PropsFileName); // Clean up
// TextWriter tw = new StreamWriter(PropsFileName); // Create & open the file
// tw.WriteLine(DateTime.Now); // Write the date for reference
// tw.WriteLine(TokenLine); // Write the BinarySecurityToken
// tw.WriteLine(ConvIdLine); // Write the ConversationId
// tw.WriteLine(ipccLine); // Write the IPCC
// tw.Close();
//Console.Read();
}
}
catch (Exception e)
{
Console.WriteLine("Exception Message : " + e.Message);
Console.WriteLine("Exception Stack Trace : " + e.StackTrace);
Console.Read();
}
}
}
}
Please Help me
I didn't check the sequence of the code in detail, but checking the values you set for organization and domain:
string ipcc = "not-understand";
string domain = "EXT";
Unless you did it intentionally to mask the values, you should have received your ipcc value from Sabre after getting a SOAP webservices account.
The value for SOAP APIs domain is normally "DEFAULT".
Registering on dev studio only gives you REST test credentials (not SOAP), so you can use this form to request SOAP test credentials:
https://developer.sabre.com/contact
Finally, I don't quite see the environment/target url you're using to test the SessionCreate service...CERT one is: https://sws3-crt.cert.sabre.com/

Blackberry Push notification using C# as server side

I am trying to send push notification in blackberry by using C# Web
service but i am facing problem is it return exception "The remote
server returned an error: (404) Not Found.". all info is correct as
per RIM Standard so please Help me ASAP.
[WebMethod]
public bool push(string notification)
{
bool success = true;
byte[] bytes = Encoding.ASCII.GetBytes("Hello");
Stream requestStream = null;
HttpWebResponse HttpWRes = null;
HttpWebRequest HttpWReq = null;
String BESName = "cp****.pushapi.eval.blackberry.com";
try
{
//http://<BESName>:<BESPort>/push?DESTINATTION=<PIN/EMAIL>&PORT=<PushPort>&REQUESTURI=/
// Build the URL to define our connection to the BES.
string httpURL = "https://" + BESName + "/push?DESTINATION=2B838E45&PORT=32721&REQUESTURI=/";
//make the connection
HttpWReq = (HttpWebRequest)WebRequest.Create(httpURL);
HttpWReq.Method = ("POST");
//add the headers nessecary for the push
HttpWReq.ContentType = "text/plain";
HttpWReq.ContentLength = bytes.Length;
// ******* Test this *******
HttpWReq.Headers.Add("X-Rim-Push-Id", "2B838E45" + "~" + DateTime.Now); //"~" +pushedMessage +
HttpWReq.Headers.Add("X-Rim-Push-Reliability", "application-preferred");
HttpWReq.Headers.Add("X-Rim-Push-NotifyURL", ("http://" + BESName + "2B838E45~Hello~" + DateTime.Now).Replace(" ", ""));
// *************************
HttpWReq.Credentials = new NetworkCredential("Username", "Password");
requestStream = HttpWReq.GetRequestStream();
//Write the data from the source
requestStream.Write(bytes, 0, bytes.Length);
//get the response
HttpWRes = (HttpWebResponse)HttpWReq.GetResponse();
var pushStatus = HttpWRes.Headers["X-RIM-Push-Status"];
//if the MDS received the push parameters correctly it will either respond with okay or accepted
if (HttpWRes.StatusCode == HttpStatusCode.OK || HttpWRes.StatusCode == HttpStatusCode.Accepted)
{
success = true;
}
else
{
success = false;
}
//Close the streams
HttpWRes.Close();
requestStream.Close();
}
catch (System.Exception)
{
success = false;
}
return success;
}
I got the same error when I tried your code above. Replace
String BESName = "cp****.pushapi.eval.blackberry.com";
With
String BESName = "cpxxx.pushapi.eval.blackberry.com/mss/PD_pushRequest";
and make sure you provide the right username and password here:
HttpWReq.Credentials = new NetworkCredential("username", "password");
I got success = true;
However, even though the above code executed successfully, I still do not see the push message on the BlackBerry device.

saaj exception - Unable to parse content type: null

I'm fairly new to webservices and working through a SAAJ example of sending and recieving attachments (binary files). I can get it to work when the client sends the file but not when it requests it. I get an exception on the client side:
ERROR: 'Content is not allowed in prolog.'
24-Oct-2012 13:59:28 com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory createEnvelope
SEVERE: SAAJ0511: Unable to create envelope from given source
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to create envelope from given source
Anybody have any ideas???my client code is as follows:
SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
SOAPConnection con = scf.createConnection();
SOAPFactory soapFactory = SOAPFactory.newInstance();
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
SOAPHeader header = msg.getSOAPHeader();
header.detachNode();
SOAPBody body = msg.getSOAPBody();
Name bodyName = soapFactory.createName(
"remoteOpen", "remoteOpen",
"http://schemas.remoteOpen.com/remoteOpen");
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
SOAPElement projectName = bodyElement.addChildElement("projectName");
projectName.addTextNode("filename");
msg.saveChanges();
// create the endpoint and send the message
URL endpoint = new URL("http://localhost:8080/RemoteSaveProject/OpenServlet");
SOAPMessage response = con.call(msg, endpoint);
con.close();
SOAPBody responseBody = response.getSOAPBody();
SOAPElement ackElem = (SOAPElement)responseBody.getFirstChild();
String acknowledgement = ackElem.getValue();
the server code looks like this:
MimeHeaders mimeHeaders = new MimeHeaders();
Enumeration en = request.getHeaderNames();
while (en.hasMoreElements())
{
String headerName = (String)en.nextElement();
String headerVal = request.getHeader(headerName);
StringTokenizer tk = new StringTokenizer(headerVal, ",");
while (tk.hasMoreTokens()){
mimeHeaders.addHeader(headerName, tk.nextToken().trim());
}
}
SOAPMessage message = mf.createMessage(mimeHeaders, request.getInputStream());
SOAPBody body = message.getSOAPBody();
Name bodyName = soapFactory.createName(
"remoteOpen", "remoteOpen",
"http://schemas.remoteOpen.com/remoteOpen");
Iterator projects = body.getChildElements(bodyName);
SOAPElement project = (SOAPElement)projects.next();
Iterator projectNameIter = project.getChildElements(soapFactory.createName("projectName"));
SOAPElement projectNameEle = (SOAPElement)projectNameIter.next();
String projectName = projectNameEle.getValue();
File file = new File(projectName);
SOAPMessage reply = mf.createMessage();
SOAPHeader header = reply.getSOAPHeader();
header.detachNode();
SOAPBody replyBody = reply.getSOAPBody();
SOAPBodyElement bodyElement = replyBody.addBodyElement(soapFactory.createName("ack"));
bodyElement.addTextNode("OK");
DataHandler dh = new DataHandler(new FileDataSource(file));
AttachmentPart attachment = reply.createAttachmentPart(dh);
attachment.setContentId("123");
reply.addAttachmentPart(attachment);
reply.saveChanges();
response.setStatus(HttpServletResponse.SC_OK);
putHeaders(reply.getMimeHeaders(), response);
response.setContentType("text/xml");
ServletOutputStream replyOS = response.getOutputStream();
reply.writeTo(replyOS);
replyOS.flush();
replyOS.close();
putHeaders looks like:
Iterator it = headers.getAllHeaders();
while (it.hasNext())
{
MimeHeader header = (MimeHeader) it.next();
String[] values = headers.getHeader(header.getName());
if (values.length == 1)
{
res.setHeader( header.getName(), header.getValue());
}
else
{
StringBuffer concat = new StringBuffer();
int i = 0;
while (i < values.length)
{
if (i != 0)
{
concat.append(',');
}
concat.append(values[i++]);
}
res.setHeader(header.getName(), concat.toString());
}
}
If you are using Google app engine, like me, the problem is that GAE doesn't support com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ParameterList which is used internally somewhere in the call chain of javax.xml.soap.SOAPConnection.call(). So you must use a workaround.
I personally did it by using java.net.HttpURLConnection instead of javax.xml.soap.SOAPConnection and manually sending and parsing SOAP messages.

Changing cell content on google spreadsheets via api 3.0

I need to change the contents of a cell on google spreadsheets.
I have successfully gotten the data via google docs api (all required authorization and options tag are set).
But I can't change the cell content. I have generated the following url and data:
req url: https://spreadsheets.google.com/feeds/cells/0AnT0uFQJWw_edENkYndfQWxCWlVmeG9oNW5kWjhYVUE/tCdbw_AlBZUfxoh5ndZ8XUA/private/full/R2C1
req data: <?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:gs='http://schemas.google.com/spreadsheets/2006'><id>https://spreadsheets.google.com/feeds/cells/0AnT0uFQJWw_edENkYndfQWxCWlVmeG9oNW5kWjhYVUE/tCdbw_AlBZUfxoh5ndZ8XUA/private/full/R2C1</id><link rel='edit' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/cells/0AnT0uFQJWw_edENkYndfQWxCWlVmeG9oNW5kWjhYVUE/tCdbw_AlBZUfxoh5ndZ8XUA/private/full/R2C1'/><gs:cell row='2' col='1' inputValue='*match found*
имя: вася
фамилия: тра та та
номер телефона дом: +7123456789
номер телефона моб: +7098765432
город: москва'/></entry>
repl data: Response contains no content type
And sometimes I recieve "bad request" in reply.
i following this document when writing code, and create this:
1. i getting cellsfeed url
NETLIBHTTPREQUEST nlhr = {0};
nlhr.cbSize = sizeof(NETLIBHTTPREQUEST);
nlhr.headersCount = 2;
nlhr.headers = (NETLIBHTTPHEADER*)malloc(sizeof(NETLIBHTTPHEADER) * (nlhr.headersCount));
nlhr.headers[0].szName = "Authorization";
if(AuthTag.empty())
{
string str;
str += "GoogleLogin auth=";
str += Auth;
AuthTag = str;
nlhr.headers[0].szValue = _strdup(str.c_str());
}
else
nlhr.headers[0].szValue = _strdup(AuthTag.c_str());
nlhr.headers[1].szName = "GData-Version";
nlhr.headers[1].szValue = "3.0";
nlhr.cbSize = sizeof(NETLIBHTTPREQUEST);
nlhr.flags = NLHRF_SSL;
{
string str = "https://spreadsheets.google.com/feeds/worksheets/";
str += toUTF8(Params.vtszDocuments[0]);
str += "/private/full";
nlhr.szUrl = _strdup(str.c_str());
}
nlhr.requestType = REQUEST_GET;
nlhr2 = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
if(!nlhr2)
{
boost::this_thread::sleep(boost::posix_time::minutes(Params.Interval));
continue;
}
using namespace rapidxml;
xml_document<> xml;
xml.parse<0>(nlhr2->pData);
Netlib_CloseHandle(nlhr2);
for(xml_node<> *node = xml.first_node()->first_node("entry"); node; node = node->next_sibling("entry"))
{
if(strcmp(node->first_node("title")->value(), toUTF8(Params.tszListName).c_str()))
continue;
bool found = false;
xml_node<> *id = node->first_node("id");
string spreadshit_id = id->value();
if(spreadshit_id.find(toUTF8(Params.vtszDocuments[0])) == string::npos)
continue;
for(xml_node<> *link = node->first_node("link"); link; link = link->next_sibling("link"))
{
if(strcmp(link->first_attribute("rel")->value(), "http://schemas.google.com/spreadsheets/2006#cellsfeed"))
continue;
cellsfeed = link->first_attribute("href")->value();
found = true;
if(found)
break;
}
if(found)
break;
}
2. i getting cellsfeed to buffer for parsing on need
base_document_xml.clear();
if(base_document_xml_buffer)
free(base_document_xml_buffer);
NETLIBHTTPREQUEST nlhr = {0};
nlhr.cbSize = sizeof(NETLIBHTTPREQUEST);
nlhr.headersCount = 2;
nlhr.headers = (NETLIBHTTPHEADER*)malloc(sizeof(NETLIBHTTPHEADER) * (nlhr.headersCount));
nlhr.headers[0].szName = "Authorization";
if(AuthTag.empty())
{
string str;
str += "GoogleLogin auth=";
str += Auth;
AuthTag = str;
nlhr.headers[0].szValue = _strdup(str.c_str());
}
else
nlhr.headers[0].szValue = _strdup(AuthTag.c_str());
nlhr.headers[1].szName = "GData-Version";
nlhr.headers[1].szValue = "3.0";
nlhr.cbSize = sizeof(NETLIBHTTPREQUEST);
nlhr.flags = NLHRF_SSL;
nlhr.szUrl = _strdup(cellsfeed.c_str());
nlhr.requestType = REQUEST_GET;
nlhr2 = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
if(!nlhr2)
{
boost::this_thread::sleep(boost::posix_time::minutes(Params.Interval));
continue;
}
using namespace rapidxml;
base_document_xml_buffer = _strdup(nlhr2->pData);
base_document_xml.parse<0>(base_document_xml_buffer); //memory leak ?
Netlib_CloseHandle(nlhr2);
3. i getting etag and edit url for needed cell
string edit_link, etag;
using namespace rapidxml;
for(xml_node<> *node = base_document_xml.first_node()->first_node("entry"); node; node = node->next_sibling("entry"))
{
xml_node<> *cell_id = node->first_node("gs:cell");
char buf[4];
_itoa(i->row +1 ,buf, 10);
if(strcmp(cell_id->first_attribute("row")->value(), buf))
continue;
_itoa(i->column +1 ,buf, 10);
if(strcmp(cell_id->first_attribute("col")->value(), buf))
continue;
for(xml_node<> *link = node->first_node("link"); link; link = link->next_sibling("link"))
{
if(strcmp(link->first_attribute("rel")->value() , "edit"))
continue;
edit_link = link->first_attribute("href")->value();
etag = node->first_attribute("gd:etag")->value();
}
}
i using Miranda IM core network library in this code, and i think all right with network part, something wrong with request url or data content in request
UPD:
i have missed content type header in first code, now i fixed this, but have another problem, google returning "premature end of file"..., code updated.
UPD2:
i have solve this problem, it caused by wrong parameters passed by netowrk library, now i have following Invalid query parameter value for grid-id., and does not understand what it means...
UPD3:
looks like i have misunderstand api, i need to rewrite some code, i will post result here...
UPD4:
i have tried to obtain edit url via different api function, but have same result ...
UPD5:
i have solved this problem, not optimal and i thnk slow way, but at least working, i implement few more api calls and addition xml parsing steps to get correct link for edit each cell, code updated if someone need this, rapidxml parsing library and miranda im core net library used here.