00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00033 #ifndef Z_GDU_H
00034 #define Z_GDU_H
00035
00036 #include <yaz/z-core.h>
00037
00038 YAZ_BEGIN_CDECL
00039
00040 typedef struct Z_HTTP_Header Z_HTTP_Header;
00041
00042 struct Z_HTTP_Header {
00043 char *name;
00044 char *value;
00045 Z_HTTP_Header *next;
00046 };
00047
00048 typedef struct {
00049 char *method;
00050 char *version;
00051 char *path;
00052 Z_HTTP_Header *headers;
00053 char *content_buf;
00054 int content_len;
00055 } Z_HTTP_Request;
00056
00057 typedef struct {
00058 int code;
00059 char *version;
00060 Z_HTTP_Header *headers;
00061 char *content_buf;
00062 int content_len;
00063 } Z_HTTP_Response;
00064
00065 #define Z_GDU_Z3950 1
00066 #define Z_GDU_HTTP_Request 2
00067 #define Z_GDU_HTTP_Response 3
00068 typedef struct {
00069 int which;
00070 union {
00071 Z_APDU *z3950;
00072 Z_HTTP_Request *HTTP_Request;
00073 Z_HTTP_Response *HTTP_Response;
00074 } u;
00075 } Z_GDU ;
00076 YAZ_EXPORT int z_GDU (ODR o, Z_GDU **p, int opt, const char *name);
00077 YAZ_EXPORT void z_HTTP_header_add(ODR o, Z_HTTP_Header **hp, const char *n,
00078 const char *v);
00079 YAZ_EXPORT void z_HTTP_header_add_content_type(ODR o, Z_HTTP_Header **hp,
00080 const char *content_type,
00081 const char *charset);
00082 YAZ_EXPORT void z_HTTP_header_add_basic_auth(ODR o, Z_HTTP_Header **hp,
00083 const char *username,
00084 const char *password);
00085
00086 YAZ_EXPORT const char *z_HTTP_header_lookup(const Z_HTTP_Header *hp, const char *n);
00087
00088 YAZ_EXPORT const char *z_HTTP_errmsg(int code);
00089
00090 YAZ_EXPORT Z_GDU *z_get_HTTP_Response(ODR o, int code);
00091 YAZ_EXPORT Z_GDU *z_get_HTTP_Request(ODR o);
00092 YAZ_EXPORT Z_GDU *z_get_HTTP_Request_host_path(ODR odr,
00093 const char *host,
00094 const char *path);
00095
00096 YAZ_EXPORT int yaz_decode_http_request(ODR o, Z_HTTP_Request **hr_p);
00097 YAZ_EXPORT int yaz_decode_http_response(ODR o, Z_HTTP_Response **hr_p);
00098 YAZ_EXPORT int yaz_encode_http_response(ODR o, Z_HTTP_Response *hr);
00099 YAZ_EXPORT int yaz_encode_http_request(ODR o, Z_HTTP_Request *hr);
00100
00101 YAZ_END_CDECL
00102
00103 #endif
00104
00105
00106
00107
00108
00109
00110
00111