httpcOpenContext now takes an HTTPC_RequestMethod parameter
This commit is contained in:
parent
448fb0453e
commit
4c89c10858
@ -10,6 +10,15 @@ typedef struct {
|
||||
u32 httphandle; ///< HTTP handle.
|
||||
} httpcContext;
|
||||
|
||||
/// HTTP request method.
|
||||
typedef enum {
|
||||
HTTPC_METHOD_GET = 0x1,
|
||||
HTTPC_METHOD_POST = 0x2,
|
||||
HTTPC_METHOD_HEAD = 0x3,
|
||||
HTTPC_METHOD_PUT = 0x4,
|
||||
HTTPC_METHOD_DELETE = 0x5
|
||||
} HTTPC_RequestMethod;
|
||||
|
||||
/// HTTP request status.
|
||||
typedef enum {
|
||||
HTTPC_STATUS_REQUEST_IN_PROGRESS = 0x5, ///< Request in progress.
|
||||
@ -31,7 +40,7 @@ void httpcExit(void);
|
||||
* @param url URL to connect to.
|
||||
* @param use_defaultproxy Whether the default proxy should be used (0 for default)
|
||||
*/
|
||||
Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy);
|
||||
Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, char* url, u32 use_defaultproxy);
|
||||
|
||||
/**
|
||||
* @brief Closes a HTTP context.
|
||||
@ -124,7 +133,7 @@ Result HTTPC_InitializeConnectionSession(Handle handle, Handle contextHandle);
|
||||
* @param url URL to connect to.
|
||||
* @param contextHandle Pointer to output the created HTTP context handle to.
|
||||
*/
|
||||
Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle);
|
||||
Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle);
|
||||
|
||||
/**
|
||||
* @brief Closes a HTTP context.
|
||||
|
@ -33,11 +33,11 @@ void httpcExit(void)
|
||||
svcCloseHandle(__httpc_servhandle);
|
||||
}
|
||||
|
||||
Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy)
|
||||
Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, char* url, u32 use_defaultproxy)
|
||||
{
|
||||
Result ret=0;
|
||||
|
||||
ret = HTTPC_CreateContext(__httpc_servhandle, url, &context->httphandle);
|
||||
ret = HTTPC_CreateContext(__httpc_servhandle, method, url, &context->httphandle);
|
||||
if(R_FAILED(ret))return ret;
|
||||
|
||||
ret = srvGetServiceHandle(&context->servhandle, "http:C");
|
||||
@ -163,14 +163,14 @@ Result HTTPC_Initialize(Handle handle)
|
||||
return cmdbuf[1];
|
||||
}
|
||||
|
||||
Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle)
|
||||
Result HTTPC_CreateContext(Handle handle, HTTPC_RequestMethod method, char* url, Handle* contextHandle)
|
||||
{
|
||||
u32* cmdbuf=getThreadCommandBuffer();
|
||||
u32 l=strlen(url)+1;
|
||||
|
||||
cmdbuf[0]=IPC_MakeHeader(0x2,2,2); // 0x20082
|
||||
cmdbuf[1]=l;
|
||||
cmdbuf[2]=0x01; // 0x01 == GET, 0x02 == POST, 0x03 == HEAD, 0x04 == PUT, 0x05 == DELETE
|
||||
cmdbuf[2]=method;
|
||||
cmdbuf[3]=IPC_Desc_Buffer(l,IPC_BUFFER_R);
|
||||
cmdbuf[4]=(u32)url;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user