lib/sw_apps/img_rcvry/src/xbir_http.c
static int Xbir_HttpSendResponse404 (struct tcp_pcb *Tpcb, u8 *HttpReq,
	u16 HttpReqLen)
{
	int Status = XST_FAILURE;
	u16 Len;
	u16 Hlen;
	char Buffer[XBIR_HTTP_404_ERR_MAX_RESPONSE_LEN];
	err_t Error;

	Len = strlen(Xbir_HttpNotFoundHdr) + strlen(Xbir_HttpNotFoundFooter) +
		HttpReqLen;

	Hlen = Xbir_HttpGenerateHdr(Buffer, "html", Len);

	if (tcp_sndbuf(Tpcb) < Hlen) {
		Xbir_Printf("ERROR : Cannot send 404 message, "
			"tcp_sndbuf = %d bytes, message length = %d bytes\r\n",
			tcp_sndbuf(Tpcb), Hlen);
		goto END;
	}

	Error = tcp_write(Tpcb, Buffer, Hlen, TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing 404 http header\r\n", Error);
		goto END;
	}

	Error = tcp_write(Tpcb, Xbir_HttpNotFoundHdr,
		strlen(Xbir_HttpNotFoundHdr), TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing not found header\r\n", Error);
		goto END;
	}

	Error = tcp_write(Tpcb, HttpReq, HttpReqLen, TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing org req\r\n", Error);
		goto END;
	}

	Error = tcp_write(Tpcb, Xbir_HttpNotFoundFooter,
		strlen(Xbir_HttpNotFoundFooter), TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing not found footer\r\n", Error);
		goto END;
	}

	Status = XST_SUCCESS;

END:
	Xbir_HttpClose(Tpcb);
	return Status;
}
/*****************************************************************************/
/**
 * @brief
 * This function dynamically generates HTTP 404 error response and sends it.
 *
 * @param	Tpcb		Pointer to TCP PCB
 * @param	HttpReq		Pointer to HTTP payload
 * @param	HttpReqLen	HTTP payload length
 *
 * @return	XST_SUCCESS if request is processed successfully
 *		XST_FAILURE if request is not processed
 *
 *****************************************************************************/
@brief
This function dynamically generates HTTP 404 error response and sends it.

@param       Tpcb            Pointer to TCP PCB
@param       HttpReq         Pointer to HTTP payload
@param       HttpReqLen      HTTP payload length

@return      XST_SUCCESS if request is processed successfully
XST_FAILURE if request is not processed
@brief This function dynamically generates HTTP 404 error response and sends it . @param Tpcb Pointer to TCP PCB @param HttpReq Pointer to HTTP payload @param HttpReqLen HTTP payload length @return XST_SUCCESS if request is processed successfully XST_FAILURE if request is not processed
static int Xbir_HttpSendResponse404 (struct tcp_pcb *Tpcb, u8 *HttpReq,
	u16 HttpReqLen)
{
	int Status = XST_FAILURE;
	u16 Len;
	u16 Hlen;
	char Buffer[XBIR_HTTP_404_ERR_MAX_RESPONSE_LEN];
	err_t Error;
	Len = strlen(Xbir_HttpNotFoundHdr) + strlen(Xbir_HttpNotFoundFooter) +
		HttpReqLen;
	Hlen = Xbir_HttpGenerateHdr(Buffer, "html", Len);
	if (tcp_sndbuf(Tpcb) < Hlen) {
		Xbir_Printf("ERROR : Cannot send 404 message, "
			"tcp_sndbuf = %d bytes, message length = %d bytes\r\n",
			tcp_sndbuf(Tpcb), Hlen);
		goto END;
	}
	Error = tcp_write(Tpcb, Buffer, Hlen, TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing 404 http header\r\n", Error);
		goto END;
	}
	Error = tcp_write(Tpcb, Xbir_HttpNotFoundHdr,
		strlen(Xbir_HttpNotFoundHdr), TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing not found header\r\n", Error);
		goto END;
	}
	Error = tcp_write(Tpcb, HttpReq, HttpReqLen, TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing org req\r\n", Error);
		goto END;
	}
	Error = tcp_write(Tpcb, Xbir_HttpNotFoundFooter,
		strlen(Xbir_HttpNotFoundFooter), TCP_WRITE_FLAG_COPY);
	if (Error != ERR_OK) {
		Xbir_Printf("ERROR: (%d) writing not found footer\r\n", Error);
		goto END;
	}
	Status = XST_SUCCESS;
END:
	Xbir_HttpClose(Tpcb);
	return Status;
}
static int Xbir_HttpSendResponse404 ( struct tcp_pcb * Tpcb , u8 * HttpReq , u16 HttpReqLen ) { int Status = XST_FAILURE ; u16 Len ; u16 Hlen ; char Buffer [ XBIR_HTTP_404_ERR_MAX_RESPONSE_LEN ] ; err_t Error ; Len = strlen ( Xbir_HttpNotFoundHdr ) + strlen ( Xbir_HttpNotFoundFooter ) + HttpReqLen ; Hlen = Xbir_HttpGenerateHdr ( Buffer , " " , Len ) ; if ( tcp_sndbuf ( Tpcb ) < Hlen ) { Xbir_Printf ( " " " \r \n " , tcp_sndbuf ( Tpcb ) , Hlen ) ; goto END ; } Error = tcp_write ( Tpcb , Buffer , Hlen , TCP_WRITE_FLAG_COPY ) ; if ( Error != ERR_OK ) { Xbir_Printf ( " \r \n " , Error ) ; goto END ; } Error = tcp_write ( Tpcb , Xbir_HttpNotFoundHdr , strlen ( Xbir_HttpNotFoundHdr ) , TCP_WRITE_FLAG_COPY ) ; if ( Error != ERR_OK ) { Xbir_Printf ( " \r \n " , Error ) ; goto END ; } Error = tcp_write ( Tpcb , HttpReq , HttpReqLen , TCP_WRITE_FLAG_COPY ) ; if ( Error != ERR_OK ) { Xbir_Printf ( " \r \n " , Error ) ; goto END ; } Error = tcp_write ( Tpcb , Xbir_HttpNotFoundFooter , strlen ( Xbir_HttpNotFoundFooter ) , TCP_WRITE_FLAG_COPY ) ; if ( Error != ERR_OK ) { Xbir_Printf ( " \r \n " , Error ) ; goto END ; } Status = XST_SUCCESS ; END : Xbir_HttpClose ( Tpcb ) ; return Status ; }
@brief
 This function dynamically generates HTTP 404 error response and sends it.
@brief This function dynamically generates HTTP 404 error response and sends it .