MCPcopy Create free account
hub / github.com/amcewen/HttpClient / startRequest

Method startRequest

HttpClient.cpp:59–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59int HttpClient::startRequest(const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aHttpMethod, const char* aUserAgent)
60{
61 tHttpState initialState = iState;
62 if ((eIdle != iState) && (eRequestStarted != iState))
63 {
64 return HTTP_ERROR_API;
65 }
66
67#ifdef PROXY_ENABLED
68 if (iProxyPort)
69 {
70 if (!iClient->connect(iProxyAddress, iProxyPort) > 0)
71 {
72#ifdef LOGGING
73 Serial.println("Proxy connection failed");
74#endif
75 return HTTP_ERROR_CONNECTION_FAILED;
76 }
77 }
78 else
79#endif
80 {
81 if (!iClient->connect(aServerName, aServerPort) > 0)
82 {
83#ifdef LOGGING
84 Serial.println("Connection failed");
85#endif
86 return HTTP_ERROR_CONNECTION_FAILED;
87 }
88 }
89
90 // Now we're connected, send the first part of the request
91 int ret = sendInitialHeaders(aServerName, IPAddress(0,0,0,0), aServerPort, aURLPath, aHttpMethod, aUserAgent);
92 if ((initialState == eIdle) && (HTTP_SUCCESS == ret))
93 {
94 // This was a simple version of the API, so terminate the headers now
95 finishHeaders();
96 }
97 // else we'll call it in endRequest or in the first call to print, etc.
98
99 return ret;
100}
101
102int HttpClient::startRequest(const IPAddress& aServerAddress, const char* aServerName, uint16_t aServerPort, const char* aURLPath, const char* aHttpMethod, const char* aUserAgent)
103{

Callers

nothing calls this directly

Calls 1

connectMethod · 0.80

Tested by

no test coverage detected