lib/sw_apps/img_rcvry/src/xbir_http.c
int Xbir_HttpSendResponseJson (struct tcp_pcb *Tpcb, u8 *HttpReq,
	u16 HttpReqLen, char *JsonStr, u16 JsonStrLen)
{
	int Status = XST_FAILURE;
	int Error;
	char Buffer[XBIR_HTTP_BUFFER_SIZE];
	u32 HdrLen;

	/* Send the HTTP headers */
	HdrLen = Xbir_HttpGenerateHdr(Buffer, "jsn", JsonStrLen);

	if (Tpcb->state > ESTABLISHED) {
		Xbir_Printf("ERROR :TCP connection is dropped\r\n");
		Xbir_HttpClose(Tpcb);
		goto END;
	}

	Error = tcp_write(Tpcb, Buffer, HdrLen,
		TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing http header to socket\r\n",
			Error);
		Xbir_Printf("attempted to write #bytes = %d, tcp_sndbuf = %d\r\n",
			HdrLen, tcp_sndbuf(Tpcb));
		Xbir_Printf("HTTP header = %s\r\n", Buffer);
		Xbir_HttpClose(Tpcb);
		goto END;
	}

	Error = tcp_write(Tpcb, JsonStr, JsonStrLen,
		TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE);
	if (Error != ERR_OK) {
		Xbir_Printf("Attempted to lwip_write %d bytes,"
			" tcp write error = %d\r\n", JsonStrLen, Error);
		Xbir_HttpClose(Tpcb);
		goto END;
	}

	Status = XST_SUCCESS;

END:
	return Status;
}
/*****************************************************************************/
/**
 * @brief
 * This function sends the HTTP Response with JSON payload.
 *
 * @param	Tpcb		Pointer to TCP PCB
 * @param	HttpReq		Pointer to HTTP payload
 * @param	HttpReqLen	HTTP payload length
 * @param	JsonStr		Json payload
 * @param	JsonStrLen	Json payload length
 *
 * @return	XST_SUCCESS if request is processed successfully
 *		XST_FAILURE if request is not processed
 *
 *****************************************************************************/
@brief
This function sends the HTTP Response with JSON payload.



@return      XST_SUCCESS if request is processed successfully
XST_FAILURE if request is not processed
@brief This function sends the HTTP Response with JSON payload . @return XST_SUCCESS if request is processed successfully XST_FAILURE if request is not processed
int Xbir_HttpSendResponseJson (struct tcp_pcb *Tpcb, u8 *HttpReq,
	u16 HttpReqLen, char *JsonStr, u16 JsonStrLen)
{
	int Status = XST_FAILURE;
	int Error;
	char Buffer[XBIR_HTTP_BUFFER_SIZE];
	u32 HdrLen;
	HdrLen = Xbir_HttpGenerateHdr(Buffer, "jsn", JsonStrLen);
	if (Tpcb->state > ESTABLISHED) {
		Xbir_Printf("ERROR :TCP connection is dropped\r\n");
		Xbir_HttpClose(Tpcb);
		goto END;
	}
	Error = tcp_write(Tpcb, Buffer, HdrLen,
		TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing http header to socket\r\n",
			Error);
		Xbir_Printf("attempted to write #bytes = %d, tcp_sndbuf = %d\r\n",
			HdrLen, tcp_sndbuf(Tpcb));
		Xbir_Printf("HTTP header = %s\r\n", Buffer);
		Xbir_HttpClose(Tpcb);
		goto END;
	}
	Error = tcp_write(Tpcb, JsonStr, JsonStrLen,
		TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE);
	if (Error != ERR_OK) {
		Xbir_Printf("Attempted to lwip_write %d bytes,"
			" tcp write error = %d\r\n", JsonStrLen, Error);
		Xbir_HttpClose(Tpcb);
		goto END;
	}
	Status = XST_SUCCESS;
END:
	return Status;
}
int Xbir_HttpSendResponseJson ( struct tcp_pcb * Tpcb , u8 * HttpReq , u16 HttpReqLen , char * JsonStr , u16 JsonStrLen ) { int Status = XST_FAILURE ; int Error ; char Buffer [ XBIR_HTTP_BUFFER_SIZE ] ; u32 HdrLen ; HdrLen = Xbir_HttpGenerateHdr ( Buffer , " " , JsonStrLen ) ; if ( Tpcb -> state > ESTABLISHED ) { Xbir_Printf ( " \r \n " ) ; Xbir_HttpClose ( Tpcb ) ; goto END ; } Error = tcp_write ( Tpcb , Buffer , HdrLen , TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE ) ; if ( Error != ERR_OK ) { Xbir_Printf ( " \r \n " , Error ) ; Xbir_Printf ( " \r \n " , HdrLen , tcp_sndbuf ( Tpcb ) ) ; Xbir_Printf ( " \r \n " , Buffer ) ; Xbir_HttpClose ( Tpcb ) ; goto END ; } Error = tcp_write ( Tpcb , JsonStr , JsonStrLen , TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE ) ; if ( Error != ERR_OK ) { Xbir_Printf ( " " " \r \n " , JsonStrLen , Error ) ; Xbir_HttpClose ( Tpcb ) ; goto END ; } Status = XST_SUCCESS ; END : return Status ; }
@brief
 This function sends the HTTP Response with JSON payload.
@brief This function sends the HTTP Response with JSON payload .
/* Send the HTTP headers */