bool WizFi210::initialise() { reset(); if(!_transport.initialise()) { if(DEBUG) Serial.println("WF:tpt:0"); return false; } else { if(DEBUG) Serial.println("WF:tpt:1"); } if(DEBUG) Serial.println("WF:init"); // Enable numerical responses sendCommand("ATV0", COMMAND_TERMINATOR); receiveResponse(); // if(!DEBUG) { // Disable echo // sendCommand("ATE0", COMMAND_TERMINATOR); // receiveResponse(); // } _transport.enableHardwareFlowControl(true); // Enalbe hardware flow control sendCommand("AT&R1", COMMAND_TERMINATOR); // Return response result return receiveResponse()->isOk(); }
TEST(ImageResourceTest, FailedRevalidationSvgToSvg) { KURL url(ParsedURLString, "http://127.0.0.1:8000/foo"); ImageResource* imageResource = ImageResource::create(ResourceRequest(url)); Persistent<MockImageResourceClient> client = new MockImageResourceClient(imageResource); receiveResponse(imageResource, url, "image/svg+xml", svgImage()); EXPECT_FALSE(imageResource->errorOccurred()); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(client->imageChangedCount(), 1); EXPECT_TRUE(client->notifyFinishedCalled()); EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); EXPECT_EQ(200, imageResource->getImage()->width()); EXPECT_EQ(200, imageResource->getImage()->height()); imageResource->setRevalidatingRequest(ResourceRequest(url)); receiveResponse(imageResource, url, "image/svg+xml", svgImage2()); EXPECT_FALSE(imageResource->errorOccurred()); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(2, client->imageChangedCount()); EXPECT_TRUE(client->notifyFinishedCalled()); EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); EXPECT_EQ(300, imageResource->getImage()->width()); EXPECT_EQ(300, imageResource->getImage()->height()); }
char* getRawBlock(int socketFd, int blockHeight) { /* Send a request */ char* msg = constructGetBlockHashJSONMsg(blockHeight); char* req = buildRequest(msg,host,username,password,0); if (msg!=NULL) free(msg); /*printf("Sending message : \n%s\n",req);*/ sendMessage(socketFd,req); /* Receive the response's body */ char* bodyStr = receiveResponse(socketFd); free(req); /* Clean up */ /* process response */ char* blockHash = extractResultStringFromJSON(bodyStr); /*printf("Response: \n%s\n",blockHash);*/ if (blockHash==NULL) return NULL; /* Send a request */ msg = constructGetBlockJSONMsg(blockHash); if (blockHash!=NULL) free(blockHash); req = buildRequest(msg,host,username,password,0); if (msg!=NULL) free(msg); /*printf("Sending message : \n%s\n",req);*/ sendMessage(socketFd,req); /* Receive the response's body */ bodyStr = receiveResponse(socketFd); free(req); /* Clean up */ /* process response */ char* rawBlock = extractResultStringFromJSON(bodyStr); return rawBlock; }
int main(void) { WSADATA Data; SOCKADDR_IN recvSockAddr; SOCKET recvSocket; int status; int numrcv = 0; struct hostent * remoteHost; char * ip; const char * host_name = "pb-homework.appspot.com"; char buffer[MAXBUFLEN]; char myArray[50]; memset(buffer,0,MAXBUFLEN); // Initialize Windows Socket DLL status = WSAStartup(MAKEWORD(2, 2), &Data); if(status != 0) { printf("ERROR: WSAStartup unsuccessful\r\n"); return 1; } // Create socket recvSocket = createSocket(); // Get IP address from host name remoteHost = gethostbyname(host_name); ip = inet_ntoa(*(struct in_addr *)*remoteHost->h_addr_list); printf("IP address is: %s.\n", ip); memset(&recvSockAddr, 0, sizeof(recvSockAddr)); // zero the sockaddr_in structure recvSockAddr.sin_port=htons(PORT); // specify the port portion of the address recvSockAddr.sin_family=AF_INET; // specify the address family as Internet recvSockAddr.sin_addr.s_addr= inet_addr(ip); // specify ip address // Connect connectToRemoteServer(recvSocket, recvSockAddr); // Send request sendRequest(recvSocket, host_name); strcpy(buffer, receiveResponse(recvSocket)); //Send request with secret param sendSecret(recvSocket, host_name, buffer); strcpy(buffer, receiveResponse(recvSocket)); strcpy(myArray, getString(recvSocket, buffer)); strcpy(myArray, arraySorting(myArray, getArraySize(myArray))); //Send POST-request with sorted array sendPOST(recvSocket, host_name, myArray); puts(receiveResponse(recvSocket)); closesocket(recvSocket); WSACleanup(); getchar(); return EXIT_SUCCESS; }
TEST(ImageResourceTest, SuccessfulRevalidationSvg) { KURL url(ParsedURLString, "http://127.0.0.1:8000/foo"); ImageResource* imageResource = ImageResource::create(ResourceRequest(url)); Persistent<MockImageResourceClient> client = new MockImageResourceClient(imageResource); receiveResponse(imageResource, url, "image/svg+xml", svgImage()); EXPECT_FALSE(imageResource->errorOccurred()); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(1, client->imageChangedCount()); EXPECT_TRUE(client->notifyFinishedCalled()); EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); EXPECT_EQ(200, imageResource->getImage()->width()); EXPECT_EQ(200, imageResource->getImage()->height()); imageResource->setRevalidatingRequest(ResourceRequest(url)); ResourceResponse response; response.setURL(url); response.setHTTPStatusCode(304); imageResource->responseReceived(response, nullptr); EXPECT_FALSE(imageResource->errorOccurred()); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(1, client->imageChangedCount()); EXPECT_TRUE(client->notifyFinishedCalled()); EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); EXPECT_EQ(200, imageResource->getImage()->width()); EXPECT_EQ(200, imageResource->getImage()->height()); }
TEST(ImageResourceTest, AddClientAfterPrune) { KURL url(ParsedURLString, "http://127.0.0.1:8000/foo"); ImageResource* imageResource = ImageResource::create(ResourceRequest(url)); // Adds a ResourceClient but not ImageResourceObserver. Persistent<MockResourceClient> client1 = new MockResourceClient(imageResource); receiveResponse(imageResource, url, "image/jpeg", jpegImage()); EXPECT_FALSE(imageResource->errorOccurred()); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(1, imageResource->getImage()->width()); EXPECT_EQ(1, imageResource->getImage()->height()); EXPECT_TRUE(client1->notifyFinishedCalled()); client1->removeAsClient(); EXPECT_FALSE(imageResource->isAlive()); imageResource->prune(); EXPECT_TRUE(imageResource->hasImage()); // Re-adds a ResourceClient but not ImageResourceObserver. Persistent<MockResourceClient> client2 = new MockResourceClient(imageResource); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(1, imageResource->getImage()->width()); EXPECT_EQ(1, imageResource->getImage()->height()); EXPECT_TRUE(client2->notifyFinishedCalled()); }
bool WizFi210::associate(const char* SSID) { // Enable text response because this command doesn't return a valid numerical response sendCommand("ATV1", COMMAND_TERMINATOR); receiveResponse(&_textResponseHandler); sendCommand("AT+WA=", SSID, COMMAND_TERMINATOR); // This command can take a bit _timeout = 15000; bool associated = receiveResponse(&_textResponseHandler)->isOk(); // Disable text response sendCommand("ATV0", COMMAND_TERMINATOR); receiveResponse(); return associated; }
// consumer for custom display printing implemented with format library void * lcd_putat(void * ap, const char *s, size_t n) { struct coord *pc = (struct coord *)ap; uint8_t data[]= {0x73, pc->x, pc->y, 0x03, 0xff, 0xff}; sendMultipleCommands(data, 6); while (n--) { // uint8_t data[]={0x54, *s, pc->x, pc->y, 0xff, 0xff}; // sendMultipleCommands(data, 6);; sendCommand(*s); pc->x++; s++; if (pc->x >= 20) { pc->x = 0; pc->y++; } } sendCommand(0x00); receiveResponse(); return (void*)pc; }
ULXR_API_IMPL(Cpp8BitString) HttpClient::msgPOST( const Cpp8BitString &msg, const CppString &type, const CppString &resource) { ULXR_TRACE(ULXR_PCHAR("msgPOST")); Cpp8BitString ret; if (!protocol->isOpen() ) protocol->open(); sendAuthentication(); protocol->sendRequestHeader(ULXR_PCHAR("POST"), resource, type, msg.length()); protocol->writeBody(msg.data(), msg.length()); StringProcessor sp (ret); receiveResponse(sp); if (getHttpStatus() != 200) throw ConnectionException(TransportError, getHttpPhrase(), getHttpStatus()); if (!protocol->isPersistent() ) protocol->close(); return ret; }
void WizFi210::setAutoTcpConnect(uint8_t *address, int port) { sendCommand("AT+NAUTO=0,1,", COMMAND_SECTION_TERMINATOR); writeIP(address), sendCommand(COMMAND_SEPERATOR, COMMAND_SECTION_TERMINATOR); print(port, DEC); sendCommand(COMMAND_TERMINATOR); receiveResponse(); }
bool WizFi210::tcpConnect(uint8_t *address, int port) { sendCommand("AT+NCTCP=", COMMAND_SECTION_TERMINATOR); writeIP(address), sendCommand(COMMAND_SEPERATOR, COMMAND_SECTION_TERMINATOR); print(port, DEC); sendCommand(COMMAND_TERMINATOR); return receiveResponse()->isOk(); }
void RegisterDialog::on_OkBtn_clicked() { /* This is for register */ Nevent ev; std::string str; //send login request //We must get server IP and port from loginconfig if(conf->serverIP.isEmpty() || conf->serverPort.isEmpty()){ qDebug() << "We must configure server IP and port first" << endl; return; } nq.setRemote(conf->serverIP, conf->serverPort); ev.req.setSessionID(0); str.insert(0, "regular"); ev.req.setType(str); userName=ui->userNameEdit->text(); userPassword1=ui->userPsw1Edit->text(); userPassword2=ui->userPsw2Edit->text(); userNickName=ui->userNickNameEdit->text(); if(userName.size()!= 0 && userPassword1 == userPassword2 && userNickName.size() != 0 ) { qDebug() << userName << userPassword1 << userNickName << endl; str.clear(); str.insert(0,"register"); ev.req.setMethod(str); ev.req.addParams(userName.toInt()); // userName str.clear(); str.insert(0, userPassword1.toLocal8Bit().data()); ev.req.addParams(str); // userPasswd str.clear(); str.insert(0,userNickName.toLocal8Bit().data()); ev.req.addParams(str); // userNickName ev.callee = (QObject *)this; strcpy(ev.signal, SLOT(receiveResponse(Response))); nq.pushEvent(ev); conf->close(); fadeEffect.startFadeInOut(FADEOUT_EXIT); loginDialog *ld = new loginDialog(); ld->show(); } else { qDebug() << "input error" << endl; return; } }
//makes screen faster void setHighSpeed() { sendCommand(0x51); sendCommand(0x0a); receiveResponse(); uint16_t ubrr = 25; UBRR1H = ubrr>>8; UBRR1L = ubrr; UCSR1B = (1<<RXEN1) | (1<<TXEN1); UCSR1C = (1<<UCSZ11) | (1<<UCSZ10); }
bool WizFi210::setNetworkParameters(uint8_t *address, uint8_t *netMask, uint8_t *gateway) { sendCommand("AT+NSET=", COMMAND_SECTION_TERMINATOR); writeIP(address); sendCommand(COMMAND_SEPERATOR, COMMAND_SECTION_TERMINATOR); writeIP(netMask); sendCommand(COMMAND_SEPERATOR, COMMAND_SECTION_TERMINATOR); writeIP(gateway); sendCommand(COMMAND_TERMINATOR, COMMAND_SECTION_TERMINATOR); return receiveResponse()->isOk(); }
void WizFi210::escapeDataMode() { if(DEBUG) Serial.println("WF:escdata"); write("+++\n"); // No new line, so put new line for logging purposes if(DEBUG) Serial.println(); // Delay of one second to exit data mode flush(); sendCommand("AT", COMMAND_TERMINATOR); receiveResponse(); }
ULXR_API_IMPL(void) HttpClient::filePUT(const CppString &filename, const CppString &type, const CppString &resource) { ULXR_TRACE(ULXR_PCHAR("filePUT")); if (!protocol->isOpen() ) protocol->open(); FILE *ifs = fopen (getLatin1(filename).c_str(), "rb"); if (ifs == 0) throw Exception(SystemError, ulxr_i18n(ULXR_PCHAR("Cannot open file: "))+filename); struct stat statbuf; if (0 != stat (getLatin1(filename).c_str(), &statbuf) ) throw Exception(SystemError, ulxr_i18n(ULXR_PCHAR("Could not get information about file: "))+filename); sendAuthentication(); protocol->sendRequestHeader(ULXR_PCHAR("PUT"), resource, type, statbuf.st_size); char buffer [ULXR_SEND_BUFFER_SIZE]; long readed; try { while (!feof(ifs)) { readed = fread(buffer, 1, sizeof(buffer), ifs); if (readed < 0) throw Exception(SystemError, ulxr_i18n(ULXR_PCHAR("Could not read from file: "))+filename); protocol->writeBody(buffer, readed); } } catch (...) { fclose(ifs); throw; } // bool eof_reached = feof(ifs); fclose(ifs); BodyProcessor bp; receiveResponse(bp); if (getHttpStatus() != 200) throw ConnectionException(TransportError, getHttpPhrase(), getHttpStatus()); if (!protocol->isPersistent() ) protocol->close(); }
int main(int argc, char ** argv) { int sock; /* Socket descriptor */ struct sockaddr_in * ServAddr; /* Server address */ unsigned short echoServPort; /* Echo server port */ char * servIP; /* Server IP address (dotted quad) */ char * stringSent; /* String to send to server */ char * stringReceived /* String send back to client*/ char echoBuffer[RCVBUFSIZE]; /* Buffer for echo string */ unsigned int echoStringLen; /* Length of string to echo */ int bytesRcvd, totalBytesRcvd; /* Bytes read in single recv() and total bytes read */ int portNum, temp; stringSent = (char *)malloc(1+150*(sizeof(char))); stringReceived = (char *)malloc(1+150*(sizeof(char))); strcpy(stringSent, "<reply> Here is a string! </reply>\n"); printf("String sent: %s\n\n", stringSent); printResponse(temp); if(argc != 2) { perror("There is not enough arguments in entered in\n"); exit(1); } servIP = argv[0]; portNum = atoi(argv[1]); sock = createSocket(servIP, portNum, ServAddr); if(sock < 0) { perror("Could not create socket\n"); exit(1); } temp = sendRequest(sock, stringSent, ServAddr); if(temp != 0) { perror("Could not send request\n"); exit(1); } temp = receiveResponse(sock, stringReceived); if(temp != 0) { perror("Could not receive string\n"); exit(1); } printResponse(stringReceived); free(stringSent); free(stringReceived); return 0; }
void initDisplay() { //autobaud sendCommand(0x55); receiveResponse(); //set text to opaque sendCommand(0x4F); sendCommand(0x01); receiveResponse(); //enable touch screen sendCommand(0x59); sendCommand(0x05); sendCommand(0x00); receiveResponse(); //set font sendCommand(0x46); sendCommand(0x03); receiveResponse(); }
/* * Handle the request issued state by checking if we have recieved * a response and going to the response received state, timing out if we haven't * haven't in a reasonable time. */ void NtpTime::requestIssued() { if(currentState == stateRequestIssued) { if(!receiveResponse()) { if(millis() > (requestIssuedMillis + 500)) // If the request has timed out { UDPClient->stop(); toWaitState(); } } } }
uint32_t NTPClient::getEpochTime(const char* host, int port, unsigned long timeout) { if (host == NULL || port < 1) { return (uint32_t)-1; } prepareRequest(); sendRequest(host, port); if (!receiveResponse(timeout)) { return (uint32_t)-1; } return parseResponse(); }
TEST(ImageResourceTest, SVGImage) { KURL url(ParsedURLString, "http://127.0.0.1:8000/foo"); ImageResource* imageResource = ImageResource::create(ResourceRequest(url)); Persistent<MockImageResourceClient> client = new MockImageResourceClient(imageResource); receiveResponse(imageResource, url, "image/svg+xml", svgImage()); EXPECT_FALSE(imageResource->errorOccurred()); ASSERT_TRUE(imageResource->hasImage()); EXPECT_FALSE(imageResource->getImage()->isNull()); EXPECT_EQ(1, client->imageChangedCount()); EXPECT_TRUE(client->notifyFinishedCalled()); EXPECT_FALSE(imageResource->getImage()->isBitmapImage()); }
bool HttpRequest::send() { mError = ""; // check that TNL understands the supplied address if(!mRemoteAddress->isValid()) { mError = "Address invalid"; return false; } S32 connectError = mSocket->connect(*mRemoteAddress); if(connectError == UnknownError) { mError = "Connect error"; return false; } if(!mSocket->isWritable(FIVE_SECONDS)) { mError = "Socket not writable"; return false; } buildRequest(); if(!sendRequest(mRequest)) { mError = "Can't send request"; return false; } string response = receiveResponse(); if(response == "") { mError = "No response"; return false; } parseResponse(response); if(getResponseCode() == 0) { mError = "Invalid response code"; return false; } return true; }
/* * Common IPC sending-receiving routine */ void srvSendReceive(void) { if(sendRequest(&ipc_packet_data) < 0) ipcerror("microsh::srvSendReceive():sendRequest() - failed"); else { int nbytes = 0; int n = 0; sleep(1); /* yet another nasty kludge */ /* looks like we need semaphores again? */ /* do */ { ipc_packet_data.reqresp = &response; nbytes = receiveResponse(&ipc_packet_data); PRINT("nbytes=%d\n", nbytes); if(nbytes < 0) { ipcerror("microsh::srvSendReceive():receiveResponse() - failed"); /*break;*/ } else { PRINT("Server's [%d] Response: ", response.srv_pid); printf("%s", response.data); fflush(stdout); PRINT("\n"); } } /*while(nbytes && n++ != 1);*/ PRINT("DONE Send/Receive\n"); if(occurs(response.data, "exit") == 0) { printf("Exit has been received. Resetting...\n"); finishIPC(&ipc_packet_data); status.connected = false; reset(); } } }
/* * A test program to start a client and connect it to a specified server. * Usage: client <hostname> <portnum> * client is this client program * <hostname> IP address or name of a host that runs the server * <portnum> the numeric port number on which the server listens */ int main(int argc, char** argv) { int sockfd; struct sockaddr_in servaddr; char response[256]; char message[256]; if (argc != 3) { fprintf (stderr, "Usage: client <hostname> <portnum>\n"); exit (1); } // parse input parameter for port information int portNum = atoi (argv[2]); // create a streaming socket sockfd = createSocket(argv[1], portNum, &servaddr); if (sockfd < 0) { exit (1); } printf ("Enter a message: "); fgets (message, 256, stdin); // replace new line with null character message[strlen(message)-1] = '\0'; // send request to server //if (sendRequest (sockfd, "<echo>Hello, World!</echo>", &servaddr) < 0) { if (sendRequest (sockfd, message, &servaddr) < 0) { close (sockfd); exit (1); } if (receiveResponse(sockfd, response) < 0) { close (sockfd); exit (1); } close (sockfd); // display response from server printResponse(response); exit(0); }
ULXR_API_IMPL(void) HttpClient::doDELETE(const CppString &resource) { ULXR_TRACE(ULXR_PCHAR("doDELETE")); if (!protocol->isOpen() ) protocol->open(); sendAuthentication(); protocol->sendRequestHeader(ULXR_PCHAR("DELETE"), resource, ULXR_PCHAR(""), 0); BodyProcessor bp; receiveResponse(bp); if (getHttpStatus() != 200) throw ConnectionException(TransportError, getHttpPhrase(), getHttpStatus()); if (!protocol->isPersistent() ) protocol->close(); }
bool Service::requestService(string SPaddress, string SPport) { Communicator comm; Socket serviceProvider; if (!comm.connectTo(SPaddress, SPport, serviceProvider)) { cerr << "Impossibile connettersi al Service Provider\n"; return false; } // Questo invio serve al Service Provider per sapere quale servizio viene richiesto if (!serviceProvider.sendString(name)) { cerr << "Errore nell'invio del nome del servizio richiesto\n"; return false; } // Questo invio serve a controllare che il nome del servizio sia corretto if (!serviceProvider.sendString(name)) { cerr << "Errore nell'invio del nome del servizio richiesto\n"; return false; } if (!sendParameters(serviceProvider, inParameters)) { cerr << "Errore nell'invio dei parametri di ingresso del servizio\n"; return false; } if (!sendParameters(serviceProvider, outParameters)) { cerr << "Errore nell'invio dei parametri di uscita del servizio\n"; return false; } Response response; if (!receiveResponse(serviceProvider, response)) { cerr << "Errore nella ricezione della risposta\n"; return false; } if (!response.getResult()) { cerr << response.getMessage() << endl; return false; } outParameters = response.getParameters(); comm.closeAllCommunications(); return true; }
bool CHttpConnection::getTraceHeader(const CUrl &url, vector<string> &header, int maxforwards) { CBTRACELN("\ngetTraceHeader\n-----------------------------------------------------"); /* ** Head-Request formulieren */ CHttpRequest request; request.setFromUrl(url); request.setRequestType(CHttpRequest::rtTRACE); request.setUserAgent(CHttpRequest::UAExplorer6); request.setMaxForwards(maxforwards); /* ** Verbindung aufbauen */ if(!connect(url)) { m_lastError="Fehler bei connect"; CBTRACELN("Fehler bei connect"); return(false); } /* ** Request senden */ if(!sendRequest(request)) { m_lastError="Fehler bei sendRequest"; CBTRACELN("Fehler bei sendRequest"); return(false); } /* ** Antwort empfangen */ if(!receiveResponse(header)) { m_lastError="Fehler bei receiveResponse"; CBTRACELN("Fehler bei receiveResponse"); return(false); } CBTRACELN("Erfolg!"); return(true); }
/** * Runs a test by sending a message to the server and comparing the result to the expected result. * * hostname - the ip address or hostname of the server given as a string * portNum - the port number of the server * req - the message for the server * expctResp - the expected response from the server or null if any response is accepted * * returns a positive value if the expected value matches the return value and zero otherwise */ int runTest(char *hostname, int portNum, char *req, char *expctResp) { int sockfd; struct sockaddr_in servaddr; char response[256]; // create a streaming socket sockfd = createSocket(hostname, portNum, &servaddr); if (sockfd < 0) { return 0; } // send request to server if (sendRequest (sockfd, req) < 0) { close (sockfd); return 0; } if (receiveResponse(sockfd, response) < 0) { close (sockfd); return 0; } fprintf(stderr, "response = %s\n", response); close (sockfd); // display response from server if (expctResp == NULL) return 1; // accept any response if (strcmp(response, expctResp) == 0) return 1; return 0; }
ULXR_API_IMPL(void) HttpClient::msgPUT(const Cpp8BitString &msg, const CppString &type, const CppString &resource) { ULXR_TRACE(ULXR_PCHAR("msgPUT")); if (!protocol->isOpen() ) protocol->open(); sendAuthentication(); protocol->sendRequestHeader(ULXR_PCHAR("PUT"), resource, type, msg.length()); #ifdef ULXR_USE_WXSTRING protocol->writeBody(msg.data(), msg.length()); #else protocol->writeBody(msg.data(), msg.length()); #endif BodyProcessor bp; receiveResponse(bp); if (getHttpStatus() != 200) throw ConnectionException(TransportError, getHttpPhrase(), getHttpStatus()); if (!protocol->isPersistent() ) protocol->close(); }
ULXR_API_IMPL(void) HttpClient::fileGET(const CppString &filename, const CppString &resource) { ULXR_TRACE(ULXR_PCHAR("fileGET")); if (!protocol->isOpen() ) protocol->open(); std::ofstream ofs (getLatin1(filename).c_str(), std::ios::out | std::ios::binary); if (!ofs.good() ) throw Exception(SystemError, ulxr_i18n(ULXR_PCHAR("Cannot create file: "))+filename); sendAuthentication(); protocol->sendRequestHeader(ULXR_PCHAR("GET"), resource, ULXR_PCHAR(""), 0); FileProcessor fp(ofs, filename); receiveResponse(fp); if (getHttpStatus() != 200) throw ConnectionException(TransportError, getHttpPhrase(), getHttpStatus()); if (!protocol->isPersistent() ) protocol->close(); }