15 #define DISABLE_DEBUGLOG
18 #include "httpsession_p.h"
21 #include <gwenhywfar/syncio.h>
22 #include <gwenhywfar/syncio_tls.h>
23 #include <gwenhywfar/syncio_http.h>
24 #include <gwenhywfar/syncio_file.h>
26 #include <gwenhywfar/misc.h>
27 #include <gwenhywfar/debug.h>
28 #include <gwenhywfar/gui.h>
46 sess->url=strdup(url);
48 sess->defaultProtocol=strdup(defaultProto);
49 sess->defaultPort=defaultPort;
71 free(sess->defaultProtocol);
72 free(sess->httpUserAgent);
73 free(sess->httpContentType);
124 return sess->httpUserAgent;
133 free(sess->httpUserAgent);
135 sess->httpUserAgent=strdup(s);
137 sess->httpUserAgent=
NULL;
146 return sess->httpContentType;
155 free(sess->httpContentType);
157 sess->httpContentType=strdup(s);
159 sess->httpContentType=
NULL;
168 return sess->httpVMajor;
186 return sess->httpVMinor;
210 (sess->defaultProtocol)?(sess->defaultProtocol):
"http",
240 "Pragma",
"no-cache");
242 "Cache-control",
"no cache");
244 if (sess->httpContentType)
246 "Content-type", sess->httpContentType);
248 if (sess->httpUserAgent)
250 "User-Agent", sess->httpUserAgent);
277 const char *httpCommand,
278 const uint8_t *buf, uint32_t blen) {
287 I18N(
"Connecting to server..."));
294 "SSL-Error connecting (%d), retrying", rv);
303 I18N(
"Retrying to connect (non-SSLv3)"));
314 I18N(
"Retrying to connect (SSLv3)"));
328 I18N(
"Could not connect to server"));
344 if (sess->httpVMajor) {
347 snprintf(numbuf,
sizeof(numbuf)-1,
"HTTP/%d.%d",
348 sess->httpVMajor, sess->httpVMinor);
349 numbuf[
sizeof(numbuf)-1]=0;
362 "Content-length", blen);
366 I18N(
"Sending message..."));
374 I18N(
"Could not send message (%d)"),
383 I18N(
"Message sent."));
401 else if (rv<200 || rv>299) {
411 if (rv==301 || rv==303 || rv==305 || rv==307) {
452 I18N(
"Receiving response..."));
454 if (rv<0 || rv<200 || rv>299) {
456 "Error receiving packet (%d)", rv);
464 I18N(
"Received continuation response."));
470 I18N(
"Response received."));
475 I18N(
"Disconnecting from server..."));
479 I18N(
"Disconnected."));
496 else if (rv<200 || rv>299) {
506 if (rv==301 || rv==303 || rv==305 || rv==307) {
562 I18N(
"Receiving response..."));
564 if (rv<0 || rv<200 || rv>299) {
566 "Error receiving packet (%d)", rv);
594 I18N(
"Received continuation response."));
602 I18N(
"Response received."));
607 I18N(
"Disconnecting from server..."));
611 I18N(
"Disconnected."));
626 I18N(
"Connecting to server..."));
633 "SSL-Error connecting (%d), retrying", rv);
642 I18N(
"Retrying to connect (non-SSLv3)"));
653 I18N(
"Retrying to connect (SSLv3)"));
667 I18N(
"Could not connect to server"));
679 I18N(
"Disconnected."));