return CA_STATUS_OK;
}
-static int __get_status_code_from_response(char * response) {
+#if defined(__TIZEN__)
+static int CAGetHTTPStatusCode(char * response) {
char *resp, *code_plus, *ptrSave;
int ret = -1;
free(resp);
return ret;
}
+#endif
static CAResult_t CATCPCreateSocket(int family, CATCPSessionInfo_t *svritem)
{
OIC_LOG_V(INFO, TAG, "try to connect with [%s:%u]",
svritem->sep.endpoint.addr, svritem->sep.endpoint.port);
-#if defined(__TIZEN__)
- char *proxy_addr = CAGetCloudAddressForProxy();
- OIC_LOG_V(INFO, TAG, "Proxy : '%s'", proxy_addr ? proxy_addr : "(nil)");
-#endif
-
// #1. create tcp socket.
int fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
if (-1 == fd)
// #5. Send HTTP CONNECT to proxy if proxy
const char *cloud_address = CAGetCloudAddressForProxy();
+ OIC_LOG_V(INFO, TAG, "Proxy : '%s'", cloud_address ? cloud_address : "(nil)");
- if(cloud_address && *cloud_address) {
+ if(cloud_address && *cloud_address)
+ {
char message[4096];
int len = sprintf(message,
"CONNECT %s HTTP/1.1\r\n"
"Host: %s\r\n\r\n", cloud_address, cloud_address
);
-
-
ssize_t l = send(fd, message, len, 0);
- if(l != len) {
- OIC_LOG_V(INFO, TAG, "failed to send HTTP CONNECT data (expected %d bytes, ret %d)", len, l);
+ if(l != len)
+ {
+ OIC_LOG_V(ERROR, TAG, "failed to send HTTP CONNECT data (expected %d bytes, ret %d)", len, l);
close(fd);
svritem->fd = -1;
return CA_SOCKET_OPERATION_FAILED;
OIC_LOG_V(INFO, TAG, "Received data : '%s'", message);
OIC_LOG_V(INFO, TAG, "Received len = %d", l);
- int status_code = __get_status_code_from_response(message);
+ int status_code = CAGetHTTPStatusCode(message);
OIC_LOG_V(INFO, TAG, "HTTP status_code : %d", status_code);
- if(status_code < 200 || status_code > 299) {
- OIC_LOG_V(ERROR, TAG, "Error, __get_status_code_from_response => %d", status_code);
+ if(status_code < 200 || status_code > 299)
+ {
+ OIC_LOG_V(ERROR, TAG, "Error, Wrong status code", status_code);
close(fd);
svritem->fd = -1;
return CA_SOCKET_OPERATION_FAILED;